Passing Parameter To Thread Starter
Posted on 2006-05-23
I have a program that needs to watch mulitple URL's to make sure they are online.
I want to create a new thread for each URL.
The problem I am having is being able to let the thread know which URL it should be checking as I can't seem to be able to pass a parameter to the thread starter.
I impliment a loop which will grab a URL and pass it to SpinUp which in turn creates the thread and initiates the module called startme.
StartMe does the actual work of checking the availability of the URL. However I need to pass the URL into StartMe so it knows which URL to check.
I have tried setting a private variable from SpinUp and let StartMe read that variable. However the thread in StartMe doesn't begin after each call to SpinUp. It seems that SpinUp starts multiple threads befor StartMe can begin.
I have tried to create StartMe with arguments however the ThreadStart method in SpinUp doesn't like that.
Any ideas on how I can do this?
Public Sub SpinUp(ByVal URL As String)
'Purpose: Create threads
' each of which will watch one url
Dim start As New ThreadStart(AddressOf Me.StartMe)
_thread = New Thread(start)
Catch ex As Exception
Public Sub StartMe()
' Check the staus of the URL