Monday, 27 July 2009

Syncronous ProgressBar status updates

Within our application we make calls to server services both synchronously and asynchronously. There are some service calls that we want to make synchronously and still be able to show the progress bar if the process is lengthy. The existing progress bar was on the UI thread and therefore never updated until the service call completed. Martin has upgraded the progress bar to overcome this limitation.

Within each DocumentViewModel, there is an internal reference counter (held in the AbstractDocumentViewModel) which keeps track of how many things are currently in progress for that document.
When this counter > 0, the progress bar (or spinning busy graphic) is shown on that document.

In order to notify it that something is in progress (usually a service call or something which will take a detectable period of time to complete), within your DocumentViewModel class, you can call :

And to notify that this action is finished with :

The method ProgressBarToggle, is threadsafe and may be called on any thread. If it is called on the UI thread in direct response to a UI event such as a button click, then the method will take care of the fact that the UI would normally not update the progress bar visibility until the event handling method was complete & fork the thread to handle outstanding UI messages and binding updates, before continuing on with the functionality of the event handling method. In effect a VB-style “DoEvents” under the covers.

[Note : This has been added to the fledgling developer document in sharepoint :
.../Leisureflexdotnet/Design%2Documents/Forms/AllItems.aspx/“Sandstorm Developer Notes Braindump.docx”]

No comments: