Hey all!

I've got questions about background workers, how they work and how to use them.

  • What do I use background workers for?
  • Can background workers freeze the program?
  • Will having multiple background workers slow down the program?
  • If the form is closed, will there be errors if the background worker is in the middle of a task?
  • Can I put time consuming code in a background worker on a timer so it does it every N seconds? But what happens if it is not finished when it is called again?


Lastly, why can I not put this code in a background worker? It gives me the error: Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on.

Code:
    Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

        Dim N As UInt32 = 0
        Dim L1 As New Label With {.Text = "0", .Location = New Point(0, 0), .Visible = True, .Enabled = True}
        Controls.Add(L1)

        Do

            N += 1
            L1.Text = N

        Loop

    End Sub
Thanks in advance!
~Nic