小编Tha*_*gBM的帖子

(Windows Phone 10)是否可以在Windows Phone 10中以编程方式编辑和添加新联系人?

我想在Windows Phone 10中以编程方式实现功能编辑和添加联系人。

可能吗?有样品吗?

windows uwp

4
推荐指数
1
解决办法
1077
查看次数

无法在backgroundTask上调用Task.Run()

我想在后台任务的线程中做一些事情,所以我尝试使用Task.Run()但它不起作用.

任何人都可以告诉我另一种在后台任务中创建线程的方法.

这是我的代码:

   public sealed class KatzBackgroundTask : IBackgroundTask
   {

    public void Run(IBackgroundTaskInstance taskInstance)
    {
        RawNotification notification = (RawNotification)taskInstance.TriggerDetails;
        string content = notification.Content;
        System.Diagnostics.Debug.WriteLine(content);
        testLoop();
    }

    async void testLoop()
    {
        await Task.Run(() =>
       {
           int myCounter = 0;
           for (int i = 0; i < 100; i++)
           {
               myCounter++;
                //String str = String.Format(": {0}", myCounter);
                Debug.WriteLine("testLoop runtimeComponent : " + myCounter);
           }
       }
       );

    }
}
Run Code Online (Sandbox Code Playgroud)

当我删除await Task.Run()for循环可以正常运行,但是当我不删除它时,for循环无法运行.

c# background-task windows-10-mobile uwp

3
推荐指数
1
解决办法
516
查看次数

标签 统计

uwp ×2

background-task ×1

c# ×1

windows ×1

windows-10-mobile ×1