I was asking about specifics with this approach earlier today here but the confused responses has me wondering if I'm going about this all wrong.
So here's the problem. I need to architect a WinForms application that periodically checks a value from some external service. If it is in a certain state the application is supposed to pop up a modal form blocking the user from interacting with the application until such time that the state changes. The blocked UI should act just like when a form is displayed using ShowDialog(). That is to say the user should not be able to interact with the ui in any way until the dialog is closed (in this case this can only be done by the application).
In my particular application I have the requirement crop up in several instances. For example, at one point the application runs a timer that repeatedly checks the value of a cell in a db table that is constantly being updated by a weighing device. If the value is below a certain threshold the user is prompted to place items on the scale - he or she may not proceed nor interact with the UI until they do so.
Every solution I have tried has been chock full of threading problems. Either the dialog won't block the UI, or the timer will not continue checking the external service or the application cannot close the form when the time comes.
This seems like a fairly standard winforms requirement and there must be a relevant design pattern that does not bring in Windows.Forms.Timer (I like keep it my views passive). How would you do this?