Nobody likes seeing the hourglass… [Keep your application responsive with BackgroundTaskManager on WPF and Silverlight]


This blog has moved to a new location and comments have been disabled.

All old posts, new posts, and comments can be found on The blog of dlaa.me.

See you there!

Comments (9)
  1. Thank you for submitting this cool story – Trackback from DotNetShoutout

  2. davehorner says:

    great work….it’s a very clean solution.  Thanks for the nice article.

    –dave

  3. mcnamaragio says:

    What if an exception is thrown in the background task?

  4. Delay says:

    mcnamaragio,

    The MSDN documentation for the DoWork event describes what happens if an exception is thrown:

    http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.dowork(VS.95).aspx

    Hope this helps!

  5. Ido Ran says:

    Hi,

    I’ve been trying to make a reusable background worker close to the one you show here.

    Your work looks good and I’ve learn from it, the obvious down-side is that your class is singleton and so can only be one instance in the whole system. You might want to have different section of your system have independent background task management.

    Also you left out the exception handling.

    Thank you,

    Ido.

  6. Delay says:

    Thanks for the feedback, Ido! It’s always great when people are able to work off of each other’s ideas to come up with even better things! :)

  7. Grant says:

    Hi,

    I'm wanting to include a BGThread manager in my VB.net code, and I'm having issues translating your class to VB.Net..

    Specifically the following…

    1. public static EventHandler<EventArgs> BackgroundTaskStarted;

    2. var backgroundTaskStartedHandler = BackgroundTaskStarted;

           if (null != backgroundTaskStartedHandler)

           {

               backgroundTaskStartedHandler.Invoke(null, EventArgs.Empty);

           }

    I would appreciate it very much if you could supply a vb.net equivelant..

  8. Delay says:

    Grant,

    I'm on vacation and don't have a compiler available at the moment – however, maybe try something like the following to get started:

    1.

    Public Shared BackgroundTaskCompleted As EventHandler(Of EventArgs)

    2.

    ' Invoke the BackgroundTaskStarted event

    Dim backgroundTaskStartedHandler = BackgroundTaskStarted

    If backgroundTaskStartedHandler IsNot Nothing Then

       backgroundTaskStartedHandler.Invoke(Nothing, EventArgs.Empty)

    End If

    If that doesn't help, maybe try one of the many VB.NET/C# code translation tools on the web. Thanks!

Comments are closed.