Running on Empty

The few things I know, I like to share.

WPF ProgressBar and Long Running Processes


Often during long running processes it is useful to indicate in the UI that the process is running.  Rather than simply locking the UI from the user it is preferable to display a progressbar.  In my current implementation I have a server side process that I know takes a maximum of 30 seconds to complete.  So when I call this process from the UI, I display a progressbar that is timed to reach it’s maximum at 30 seconds.

The ProgressBar Window

<Windown ...>

      <ProgressBar x:Name="MessageProgessBar"
                   Maximum="100" Minimum="0"
                   Height="25" Width="275">
          <EventTrigger RoutedEvent="ProgressBar.Loaded">
                <DoubleAnimation Storyboard.TargetName="MessageProgessBar"
                                 From="0" To="100" Duration="0:0:30"/>

Calling Long Running Processes

//Open the Progressbar Window.
ThreadStart ts = delegate
 Dispatcher.BeginInvoke(DispatcherPriority.Normal, (EventHandler)
         // Do Cleanup Process HERE!               
        }, null, null);
ts.BeginInvoke(null, null);

Thank you Linda for your comments and reminder of subjects I have yet to post.

Please feel free to leave comments or suggestions.

January 23, 2009 - Posted by | C#, WPF, XAML


  1. scope of article is very small, disappointed.

    Comment by chinna | September 9, 2009 | Reply

  2. I was curious but it dosent look like you are keeping up your RoeEngine tutorials anymore is this true?

    Comment by robert | October 29, 2009 | Reply

  3. Please let me know

    Comment by robert | October 29, 2009 | Reply

  4. It seems a shame the roeengine tutorials have stopped. It would seem you have given up on this website?

    Comment by Ben | February 28, 2010 | Reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: