Hi,
I have many cyclic operations in my windows application. These operations must be called in a period of 1 second. And this operations must be run underground.
in .Net there are Windows.Forms.T imer, System.Threadin g.Timer and a Thread function running a loop with Sleep(1000) inside. Now i want to decide which one is better to use.
1. Creating System.Windows. Forms.Timer
2. Creating System.Threadin g.Timer
3. Creating a function like :
Which one is the efficient way?
I have many cyclic operations in my windows application. These operations must be called in a period of 1 second. And this operations must be run underground.
in .Net there are Windows.Forms.T imer, System.Threadin g.Timer and a Thread function running a loop with Sleep(1000) inside. Now i want to decide which one is better to use.
1. Creating System.Windows. Forms.Timer
2. Creating System.Threadin g.Timer
3. Creating a function like :
Code:
void StartMyTimer()
{
Thread thread = new Thread(new ThreadStart(CheckTask));
thread.IsBackground = true;
thread.Start();
}
void CheckTask()
{
while(true)
{
// do job
Thread.Sleep(1000);
}
}
Comment