AsyncHelper for VB.NET

By Fons Sonnemans, posted on
1625 Views

I received a mail today from Rolf Gasber asking me whether I could help him with a VB.NET version of the AsyncHelper which I used in an earlier post. Here it is:

Public

Class AsyncHelper

    Private Delegate Sub DynamicInvokeShimProc( ByVal d As [Delegate], _
                                
ByVal args() As Object )

    Private Shared _dynamicInvokeShim As _
                                 
New DynamicInvokeShimProc( AddressOf DynamicInvokeShim)

    Private Shared _dynamicInvokeDone As _
                                  
New AsyncCallback( AddressOf DynamicInvokeDone)

    Public Shared Sub FireAndForget( ByVal d As [Delegate], _
                                 
ByVal ParamArray args() As Object )
        _dynamicInvokeShim.BeginInvoke(d, args,
AddressOf _
                                
 DynamicInvokeDone, Nothing )
    End Sub

    Private Shared Sub DynamicInvokeShim( ByVal d As [Delegate], _
                                  
ByVal args() As Object )
       d.DynamicInvoke(args)
    End Sub

    Private Shared Sub DynamicInvokeDone( ByVal ar As IAsyncResult)
      
_dynamicInvokeShim.EndInvoke(ar)
    End Sub

End

Class

Tags

VB

All postings/content on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or sponsors. The content on this site is licensed under a Creative Commons Attribution By license.

Leave a comment

Blog comments

0 responses