E
esource
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
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