public StartPage()
{
NavigationPage.SetHasNavigationBar(this, false);
InitializeComponent();
Task.Run(() =>
{
Scan_Function();
});
}
在
Scan_Function()
bleText
标签动态更改:
public void Scan_Function()
{
Stopwatch sw = new Stopwatch();
sw.Start();
while (sw.Elapsed.TotalMilliseconds <= 10000)
{
if (sw.Elapsed.TotalMilliseconds >= 1000 && sw.Elapsed.TotalMilliseconds <= 1050)
{
bleText.Text = "Scanning.";
}
else if (sw.Elapsed.TotalMilliseconds >= 2000 && sw.Elapsed.TotalMilliseconds <= 2050)
{
bleText.Text = "Scanning..";
}
....... continues
}
sw.Stop();
bleText.Text = "Couldn't connect";
bleText.TextColor = Color.Red;
}
我正在从调用Scan\u函数()
Task.Run()
但我的问题是,什么都没发生!我怀疑这辆车出了问题
bleText.Text
,因为我的调试器到达它,并且似乎在没有更新任何内容或跳出循环的情况下被卡住。
文本。文本
在圈外。