I have a class that has purely static Methods and properties. I am calling an async method on the class “Load” that asks a web service for a chunk of data, which then fires an event that executes the return method, “LoadCompleted”. I have no idea how long the call is going to take (the difference between calling the “Load” method, then the “LoadCompleted” getting called).
I would like to block the application from proceeding any further until the callback method has been raised (as the app will try and get stuff from this class, which isn’t populated until the “LoadComplete” method sets the data).
How would i go about doing this?
Blocking the main UI thread should be avoided with extreme prejudice.
I would use the
BusyIndicatorcontrol from the Silverlight Toolkit:-Before calling
Loaduse:-then on
LoadCompleteuse:-This will lock out user input on the UI without blocking the main thread and give the use some feedback as to why they can’t click anything right now. You can supply your own content for the busy message using the
BustContentproperty. Of course if you don’t like the way it looks you can style it to your preference.If you want to get all MVVM you can bind the
IsBusyproperty to a VM property that indicates that the VM doesn’t want anything changing right now.