Is it right that 'System.Threading.Thread' douesn't exist in Windows Store Apps? And if it is, what is the replacement (I want to run a function in the background so the UI douesn't freez while calculating something). Language is C# and XAML for the UI.
Use Task.Run
or 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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.