I've asked a couple of questions about threading in VB.NET recently as I'm very new to it, but there's one more thing that I can't figure out. My previous question (http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_24140554.html
) related to raising events in the main thread when a background thread has completed. I got this working nicely with delegates and .Invoke(), but now I'm looking to encapsulate the bulk of my program in a class.
I want to be able to instantiate a class from from my main thread; it should be able to run some of its processes in a background thread, but raise events on the main thread. I can do this fairly easily by using delegates and passing a reference to my form into the class and using formReference.Invoke(), but ideally I want everything to do with threading to be handled within the class. The class should remain generic so that when it is reused, it just needs to be created WithEvents() rather than people having to mess about passing a reference to the creating form.
I've included some simple code and would greatly appreciate any help towards raising an event in my main thread. Apologies if I've butchered the lingo of multithreading (pretty sure I have) :P
Public Class Class1
Public Event complete()
Public Sub New()
Dim backgroundThread As System.Threading.Thread
backgroundThread = New System.Threading.Thread(AddressOf backgroundWorker)
Private Sub backgroundWorker()