tags:

views:

36

answers:

3

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 MainWindow : Window
{
    void RegularTimelyEventOccoured() {

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

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

Martin Harris
A: 

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

mdm20
A: 

I think , if it just waiting for 2 mins than use Thrad.sleep() method.

saurabh