Bohn
Bohn

Reputation: 26929

Timers inside a Child form

If I have a form that has a timer to check for some stuff in its toolbar button and now I use this form as a child form insde another application, does the timer still run? any possible threading issue that might cause it to stop working? The reason I am asking is that I have such a scenario and the toolbars are not updated if I open this app in another app, wanted to make see if the issue is coming from here and any possible fixes?

Upvotes: 0

Views: 291

Answers (1)

Kevin Wienhold
Kevin Wienhold

Reputation: 331

A System.Windows.Forms.Timer will raise its Tick event on the same thread it was created on, so if the parent application somehow blocks its main thread, the code in the Tick event will not get run until the thread clears, this might be the cause of the issue you are seeing, however, the rest of the UI should be unresponsive in that scenario as well. A System.Timers.Timer will raise its Tick event on a seperate thread, however this will be of little use if your UI thread is being blocked anyways, since this would prevent you from updating the toolbar even if the code runs.

Upvotes: 2

Related Questions