none
BackgroundTask无法命中断点? RRS feed

  • 问题

  • 如下图所示我的BackgroundTask无法命中断点也就是无法触发,请问是什么原因?

    如下是简单的代码我自己未发现有什么问题,有错误请指出

        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();
            }
            public const string TimeTriggeredTaskEntryPoint = "BackgroundTask.msiBackgroundTask";
            public const string TimeTriggeredTaskName = "msiBackgroundTaskName";
            public void UnregisterBackgroundTasks(string name)
            {
                foreach (var cur in BackgroundTaskRegistration.AllTasks)
                {
                    if (cur.Value.Name == name)
                    {
                        cur.Value.Unregister(true);
                    }
                }
            }
            private async void RegisterBackgroundTask(object sender, RoutedEventArgs e)
            {
                foreach (var task in BackgroundTaskRegistration.AllTasks)
                {
                    if (task.Value.Name == TimeTriggeredTaskName)
                    {
                        return;
                    }
                }
                //await BackgroundExecutionManager.RequestAccessAsync();
                var builder = new BackgroundTaskBuilder();
                builder.Name = TimeTriggeredTaskName;
                builder.TaskEntryPoint = TimeTriggeredTaskEntryPoint;
                //builder.SetTrigger(new TimeTrigger(15, false));
                builder.SetTrigger(new SystemTrigger(SystemTriggerType.TimeZoneChange, false));
                builder.Register();
            }
            private void UnRegisterBackgroundTask(object sender, RoutedEventArgs e)
            {
                UnregisterBackgroundTasks(TimeTriggeredTaskName);
            }
        }
          <VisualElements DisplayName="msiBackgroundTask" Logo="Assets\Logo.png" SmallLogo="Assets\SmallLogo.png" Description="msiBackgroundTask" ForegroundText="light" BackgroundColor="#464646">
            <DefaultTile ShowName="allLogos" />
            <SplashScreen Image="Assets\SplashScreen.png" />
          </VisualElements>
          <Extensions>
            <Extension Category="windows.backgroundTasks" EntryPoint="BackgroundTask.msiBackgroundTask">
              <BackgroundTasks>
                <Task Type="systemEvent" />
              </BackgroundTasks>
            </Extension>
          </Extensions>

    2012年12月21日 2:53

答案

全部回复

  • 把BackgroundTask放在WinMD文件里面


    Sheldon _Xiao
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2012年12月25日 10:05
  • 说明下:

    如截图所示我的后台任务已经为Windows运行时组建了;可依然会出现如图无法命中断点的情况;

    后来我在调试时设置->选项与设置->调试,符号,点击加载所有符号;

    然后有时就可以了,不过有时关闭工程再打开时候又无法命中断点;

    很奇怪;

    2012年12月26日 2:21