dotnet thoughts 

a dotnet developer's technical blog

Generic delegates in .Net 3.5

In my previous post I talked about Calling Synchronous methods asynchronously using delegates. But while working with .Net 3.5, there are few new concepts like Generic delegates, which helps you to call the methods asynchronously without creating a delegate.

Code using action delegate, which can be used for methods, which doesn’t returns anything


Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim c As New Action(Of String)(AddressOf LongProcess)
c.BeginInvoke("Hello", Nothing, Nothing)
End Sub
Sub LongProcess(ByVal Msg As String)
Threading.Thread.Sleep(5000)
MessageBox.Show(Msg)
End Sub
End Class

You can find more information about this on MSDN : Action generic delegate and Func generic delegate

No Responses to “Generic delegates in .Net 3.5”

RSS feed for comments on this post. TrackBack URL

Leave a Response

*