标签:
要实现后台任务,需要实现IBackgroundTask接口
1 public sealed class SimpleTask : IBackgroundTask 2 { 3 public void Run(IBackgroundTaskInstance taskInstance) 4 { 5 // TODO 6 } 7 }
假设需要用到异步方法,则要这么写:
1 public sealed class SimpleAsyncTask : IBackgroundTask 2 { 3 public async void Run(IBackgroundTaskInstance taskInstance) 4 { 5 BackgroundTaskDeferral deferral = taskInstance.GetDeferral(); 6 // TODO 7 deferral.Complete(); 8 } 9 }
标签:
原文地址:http://www.cnblogs.com/h82258652/p/4184985.html