Threading won't work on a function with parameters
- From: esource <darrenpaul@xxxxxxx>
- Date: Wed, 14 Nov 2007 14:35:46 -0800
Hi all,
I'm trying to use threading model in my web service but addressof does
not work with functions
I'm using VS 2005
my code:
Public Function Start() as Boolean
Dim MyThread As New Thread(AddressOf DoSomething)
MyThread.SetApartmentState(ApartmentState.STA)
MyThread.Start()
End Function
Private Function DoSomething(stuff as string) as string
msgbox stuff
End Function
error is:
Overload resolution failed because no accessible 'New' can be called
with these arguments:
'Public Sub New(start As
System.Threading.ParameterizedThreadStart)': Method 'Private Function
DoSomething(stuff As String) As String' does not have the same
signature as delegate 'Delegate Sub ParameterizedThreadStart(obj As
Object)'.
'Public Sub New(start As System.Threading.ThreadStart)': Method
'Private Function DoSomething(stuff As String) As String' does not
have the same signature as delegate 'Delegate Sub ThreadStart()'.
Why is it trying to compare against the delegate
ParameterizedThreadStart?
If I do it this way it works fine:
Public Function Start() as Boolean
Dim MyThread As New Thread(AddressOf DoSomething)
MyThread.SetApartmentState(ApartmentState.STA)
MyThread.Start()
End Function
Private Sub DoSomething(stuff as object)
dim x as new object
x = stuff
End Sub
but this does not help me out. I need a function not a procedure
any help appreciated. thanks
.
- Follow-Ups:
- Re: Threading won't work on a function with parameters
- From: Armin Zingler
- Re: Threading won't work on a function with parameters
- From: Spam Catcher
- Re: Threading won't work on a function with parameters
- Prev by Date: Re: How to open a pdf file that has been embedded as a resource
- Next by Date: Re: How to open a pdf file that has been embedded as a resource
- Previous by thread: How to open a pdf file that has been embedded as a resource
- Next by thread: Re: Threading won't work on a function with parameters
- Index(es):
Relevant Pages
|