Here I will explain how to call function using thread. First of all create a function and create one thread in it. then after give a function name to thread for call it.
Finally, call the Thread. Start method to run test() function and test() function call CheckThread() function.
every 20 second thread will automatically call CheckThread() function.
- private void FrmEmailer_Load(object sender, EventArgs e)
- {
- StartUtility();
- }
- private void StartUtility()
- {
- Thread thread = new Thread(new ThreadStart(test));
- thread.Start();
- }
- public void test()
- {
- while (true)
- {
- Thread.Sleep(20000);
- CheckThread();
- }
- }
- public void CheckThread()
- {
- }