Create and Run BackGroundWorker Components at Runtime with

Good morning and hope everyone had a great weekend.

It’s my birthday. At this point you can keep them folks. The big "40". That’s right folks. I am officially old as dirt. I have the ribbon my daughter gave me to prove it! It just happens to say "Old As Dirt"! I also got a basketball hoop to put up in my driveway (a must have for anyone with kids I think), and a box of Skittles. I LOVE Skittles but they don’t love me. Tonight I think my wife is taking me out to eat. We shall see.

Well my little girl went away for a week to camp this weekend. She had such a hard time having her mom leave. Its taking everything in me right now not to go up to the camp and get her after hearing how she cried when mom left and begged her to stay. I know this is part of the process of growing up so I am not going to. Still, it is not easy to hear your daughter struggling like this.

Other than that my weekend was good. 

Anyway, we want to create and run BackGroundWorker components at Runtime. Pretty easy stuff but it is what I was working on yesterday. If you are at all familiar with threading, its really not that big of a leap. Have a good day!

Imports System.ComponentModel
Public Class Form1
    Private m_WorkerList As New List(Of BackgroundWorker)
    Private Sub StartWorkers()
        Dim worker As New BackgroundWorker()
        AddHandler worker.RunWorkerCompleted, AddressOf JobDone
        AddHandler worker.DoWork, AddressOf DoJob
    End Sub
    Private Sub DoIt()
    End Sub
    Private Sub DoJob(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
    End Sub
    Private Sub JobDone(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs)
    End Sub
End Class
  1. #1 by Frank on July 21, 2008 - 9:50 am

    Happy birthday.  Been thinking of adding some comments to some of your posts, I have some feedback for C# versions of the things you post, I just haven\’t gotten my lazy butt to actually start typing.  I eventually will.

  2. #2 by Jennifer on July 21, 2008 - 1:29 pm

    Happy Birthday!  Thanks for all the tips in your blog.

  3. #3 by Stuart Baron (nora) on May 19, 2016 - 7:46 am

    BUT…. how would i use this in a class that doesn’t contain the sub/functions that i’m going to use with it without typing out ‘addressof’ each time ?… I’m trying to put all this into a Class that handles everything itself. I’m just stuck on passing the sub/functions to the class without using delegates, as delegates don’t really save any lines of code.

    I’m basically trying to remove the need for typing out the ‘AddressOf’ part and can’t see to crack it.

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: