Given the following code,
Public class ProgressFormMan ager
Public Sub BeginInvoke(ByV al method As [Delegate], ByVal args() As Object)
Dim asyncCallback As New System.Threadin g.WaitCallback( method)
System.Threadin g.ThreadPool.Qu eueUserWorkItem (asyncCallback, args)
End Sub
.... [other implementation details]
End Class
[in the Form codebehind]
Private Sub Button1_Click(. ..
Dim pfm as new ProgressFormMan ager(Me) 'Me is the form to become the
owner
pfm.BeginInvoke (addressof LongMethodCallb ack, new object() { arg1, arg2,
arg3 })
End Sub
Private Sub LongMethodCallb ack(byval param as object)
Dim args() as object = DirectCast(para m, object())
'do lengthy work
End Sub
since ProgressFormMan ager attempts to keep the form created on the same
thread as the caller and then fork a worker thread, I'm using the
QueueUserWorkIt em
problem follows:
A) Vb compiler fails on in ProgressFormMan ager.BeginInvok e with two errors:
1) 'System.Threadi ng.WaitCallback ' is a delegate type. Delegate construction
permits only a single AddressOf expression as an argument list. Often an
AddressOf expression can be used instead of a delegate construction.
2) 'AddressOf' expression cannot be converted to 'System.Delegat e' because
'System.Delegat e' is not a delegate type.
any ideas?
I know in C# this wouldnt even be a problem.
--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
er**@cc.ensoft-software.com [remove the first "CC."]