小编Sap*_*Sap的帖子

我们如何在WinRT应用程序中设置计时器?

我正在尝试在我的Windows应用商店应用中设置Timer.

    public void Start_timer()
    {

        Windows.UI.Xaml.DispatcherTimer timer = new DispatcherTimer();           
        timer.Tick += new Windows.UI.Xaml.EventHandler(timer_Tick);
        timer.Interval = new TimeSpan(00, 1, 1);
        bool enabled = timer.IsEnabled;              // Enable the timer
        timer.Start();                              // Start the timer      
      }
Run Code Online (Sandbox Code Playgroud)

在按钮上单击我调用上面的方法来设置此计时器.但是当设置了Tickhand的Eventhandler时,我得到错误"尝试读取或写入受保护的内存.这通常表明其他内存已损坏."

我们是否需要在Windows应用商店应用中以不同方式处理定时器?

c# windows-8 windows-runtime

11
推荐指数
1
解决办法
1万
查看次数

吐司通知不起作用

下面的方法在调用set Toast时执行,但是在时间弹出后不显示任何Toast.Windows 8 Metro应用程序Toast通知是否需要更多设置

 int scheduledToastCounter = 1;

    public void Set_Future_Toast()
    {

            XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

            XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
            stringElements.Item(0).AppendChild(toastXml.CreateTextNode("Scheduled Toast"));

            DateTimeOffset displayTime = DateTimeOffset.UtcNow.AddSeconds(3);

            ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, displayTime);
            scheduledToast.Id = "Future_" + this.scheduledToastCounter++;

            ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();
            notifier.AddToSchedule(scheduledToast);

            int scheduledToastCount = notifier.GetScheduledToastNotifications().Count;
        }

     }
Run Code Online (Sandbox Code Playgroud)

toast microsoft-metro windows-8

2
推荐指数
1
解决办法
4567
查看次数

标签 统计

windows-8 ×2

c# ×1

microsoft-metro ×1

toast ×1

windows-runtime ×1