开发者

What event should I monitor for a timely task in WPF?

I am writing a WPF application using C#. I need the application to continue to run for two minutes and then perform some maintenance. The user may not be interacting with it so user driven events are not guaranteed.

What is the event I should be monitoring to fulfill this requirement?

Here is some pseudo code of what I am considering:

public partial class MainW开发者_Python百科indow : Window
{
    void RegularTimelyEventOccoured() {

        if (timer >= 2 minutes) {
            DoMaintenance();
        }
    }
}


Create a DispatcherTimer at application startup and wire up to its Tick event.


Use a timer control? Theres a bunch of them. Just start the timer when the application loads and set the interval to 2 minutes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜