Multimobile Development: Building Applications for any Smartphone
Deleget.BeginInvoke.............missing? How do I make async delegate calls. Help!
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vb.


Craig
GOOD ANSWER
I need to make an asynchronous delegate call in vb and I noticied
there is no BeginInvoke. It appears only the C# compiler supports
this.

How do I make an async delegate calll???

By the way it appears that BeginInvoke for the Controls is not truly
asynchronous either (at least when I process events via remoting)
Reply to this message...
Vote that this is a GOOD answer... (2 votes from other users already)
 
 
    
VBDotNet Team [MS]
GOOD ANSWER
Hi Craig,

To make an asynchronous delegate call in vb, you need to:

1) Declare a delegate function with same signature as the procedure
2) Create a procedure delegate instance from a procedure using the AddressOf
operator
3) Call BeginInvoke on the delegate, passing in a callback function

Here's an example that asynchronously calls the Run method when the class
DelegateTest is created

Class DelegateTest

Public Delegate Sub AsyncDelegate()

Public Sub New()
Dim RunDelegate As AsyncDelegate = AddressOf Run
RunDelegate.BeginInvoke(AddressOf Callback, RunDelegate)
End Sub

Public Sub Callback(ByVal ar As IAsyncResult)
ar.AsyncState.EndInvoke(ar)
End Sub

Public Sub Run()
System.Threading.Thread.Sleep(2000)
End Sub

End Class

Hope this helps,
Ernest and Sunder
VB.NET

--
This posting is provided "AS IS" with no warranties, and confers no rights.

"Craig" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
 
System.IAsyncResult
System.Threading.Thread




Multimobile Development: Building Applications for any Smartphone
Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Multimobile Development: Building Applications for any Smartphone
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734