I have a timer named SendTimer, the interval is 30 secs.
protected void SendTimer_Tick(object sender, eventArgs e)
{
SendTimer.Enabled = false;
TransferMoney();
System.Threading.Thread.Sleep(15000);
GenerateTransactions();
SendTimer.Enabled = true;
}
I expected tick event to be called correctly by one thread at the same time. NOT by 2 threads simultaneously. but as I saw in my LOGS it seems to be called by a thread while another thread was in action. Any Idea? Because I disable and enable it respectively.
Windows Forms Timer is a single-threaded by definition. It has nothing about multithreading, because it elapses via WM_TIMER message, being sent to current GUI thread message queue.
So, this:
is incorrect, because even if you have several threads, WinForms Timer has nothing to do with this.