jal*_*mes 0 c# xaml multithreading windows-store-apps
Windows Store应用程序中不存在'System.Threading.Thread'是正确的吗?如果是,那么替换是什么(我想在后台运行一个函数,所以UI在计算某些东西时不会自由).用户界面的语言是C#和XAML.
使用Task.Run或Task.Factory.StartNew
private void BackgroundWork() { ... }
public async Task DoUsefulWorkAsync()
{
// Do useful work
// Start Background Job
Task backgroundWorkTask = Task.Run(() => BackgroundWork());
// Do more useful work
// Wait async for BackgroundWork to complete
// It won't block the UI thread that we're running on
await backgroundWorkTask;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1285 次 |
| 最近记录: |