Progress Bar - User Interface Events

Topics: CAB & Smart Client Software Factory
Dec 6, 2007 at 10:08 AM

Hi all

On the Main Status Strip of the ShellLayoutView I’ve added a hidden ToolStripProgressBar (with Marquee style set) and then in the ShellLayoutViewPresenter I’ve got the following code:

EventSubscription(EventTopicNames.ProgressStart, ThreadOption.UserInterface)
public void ProgressStartHandler(object sender, EventArgs<string> e)

In the View StartProgressBar simply makes the ToolStripProgressBar visible and forces a refresh of he main status strip (to force a redraw).

Now in a Service Module, a logon box appears if the user hasn’t been authenticated. When the user clicks the “OK” button it calls the _presenter.LoginUser. This in turn raises an event to say that we’re doing something via the call

EventTopic etStart = WorkItem.RootWorkItem.EventTopicsConstants.EventTopicNames.ProgressStart;
etStart.Fire(this, new EventArgs<string>( String.Format("Authenticating {0}", userName)), null, PublicationScope.Global);

Now the event is fired OK and the progress bar is displayed but it seems the thread for updating the UI after that point is blocked as the progress bar “hangs”. Interestingly if you put on a Timer on the ShellLayoutView which just updates the Status Label of the Status Strip with the current time, when I’m logging in (to a web service) the time will stop. So I guess it’s being blocked. Now I understand about UI thread affinity and there are ways round the problem with Invoking but I thought SCSF handles all this for you under the covers via ThreadOption.UserInterface or am I expecting too much magic?

I guess the problem is the call to the _presenter.LoginUser as it’s the UI that calls the presenter .. and then waits for the logon process to occur (as there may be errors), which in turn hangs the UI thread.

I’m new to CAB and SCSF so I’d appreciate any direction you can give.