M
Mike Bird
I have a WinForms application with a timer. When the timer tick event is
running, I may pop up a MessageBox. Since the message box can cause me to
be inside the timer tick event handler for a long period of time, I wanted
to ensure that all future timer ticks are ignored until I exit process the
current one.
I have tried a lock(timerInstance) around the timer code with no luck.
I have tried a Monitor.TryEnter(timerInstance, 0) around the timer code,
also no help.
I have tried creating a Mutex for my class and performing a Mutex.WaitOne(0,
false) around my timer code with no success.
It appears that timer event and thread synchronization do not mix, but I am
at a loss as to why this would be. Anyone have any idea why none of these
works?
running, I may pop up a MessageBox. Since the message box can cause me to
be inside the timer tick event handler for a long period of time, I wanted
to ensure that all future timer ticks are ignored until I exit process the
current one.
I have tried a lock(timerInstance) around the timer code with no luck.
I have tried a Monitor.TryEnter(timerInstance, 0) around the timer code,
also no help.
I have tried creating a Mutex for my class and performing a Mutex.WaitOne(0,
false) around my timer code with no success.
It appears that timer event and thread synchronization do not mix, but I am
at a loss as to why this would be. Anyone have any idea why none of these
works?