c# - Why is my WPF splash screen progress bar out of sync with the execution of the startup steps? -


I have implemented a simple WPF splash screen window which notifies the user about the progress of the startup.

The startup steps are defined as:

  var bootsequence = new [] {new {do = (action) InitLogging, message = "Init logging. "}, New {new = (action) UserLogOn, message =" what = (action) InitNHibernate, message = "Init NHibernate ..."}, new {what = (action) SetupUnityContainer, message = "Init unity .. "Logon ..."}, new {doo = (action) prefetadata, message = "caching ..."}}};  

InitLogging etc are defined, which takes some time consuming function.

The boot sequence is executed in this way:

  foreach (different steps in boot suumas) {_status.Update (step.Message); Step.Do (); }  

_status My XAML splash with a progress bar shows an example of a label for the screen window and status information. Its update () method is defined as follows:

  Public Zune update (string status) {int value = + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Update (status, value); } Private Zero update (string status, int value) {var dispatcher Operation = Dispatcher. Beninwok (Dispatcher Priority Background, ThreadStart) Representative {lblStatus.Content = status; ProgressBar.Value = value;}); DispatcherOperation.Wait (); }  

In the main work, the steps are executed and the splash screen shows progress. But I noticed that for some reasons the splash screen does not update its content for all the steps. That's why I called Dispatcher ASCIN and waited for its completion. But it also does not help.

Has anyone experienced this or some similar behavior and there is some advice on how to update the splash screen in synchronization with the execution of boot sequence steps? I know that users will not be expected of this behavior because the splash screen is doing something and after the booting is complete the app starts. But I'm not sleeping well, because I do not know why it is not expecting ...

Thank you for your help, Denny

My guess is the priority of operation operation. As you can see only the value 4 in DispatcherPriority.Background . It will be executed after the other queued action after this.
I think, if you have DispatcherPriority.Normal .


Comments