Main thread of application is doing some work.
There also exists a timer, which should every 10 minutes call some method which should run asynchronous.
Could you please give me a good example how to organize this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would not recommend using an explicit thread with a loop and sleep. It’s bad practice and ugly. There are timer classes for this purpose:
If this is not a GUI app, then you can use System.Threading.Timer to execute code on a different thread periodically.
If this is a WinForms/WPF app take a look at System.Windows.Forms.Timer and System.Windows.Threading.DispatcherTimer respectively. These are handy because they execute their code on the GUI thread, thus not needing explicit
Invokecalls.The links also contain examples for each one.