Is it possible for windows event and Windows timer event to execute re-entrantly?
I have "Update" method which is executes in event handler (button click), and in Windows forms Timer callback. Is it possible for two "Update" (re-entrancy) to be开发者_JS百科 executing at the same time? That is, while the timer callback is executing (calling Update method), the user clicks the button, and the click handler executes Update.
Or, is it the case that, the two Update methods are completely serialized since both execute in the UI thread.
Or, is it the case that Update could put the thread in some kind of "Alertable Wait" (I am not very clear on this), and the Click Handler could execute an as APC?
You can see, I am totally mixed up on this...
Any explanations will be highly appreciated!
It depends on a sort of the timer used: one that executes on the main UI thread (System.Windows.Forms.Timer - re-entrancy is impossible) or one executed in its own thread (System.Threading.Timer - re-entrancy is possible).
精彩评论