Library tutorials & articles

Exploring Delegates

Introduction

Delegates are a kind of type safe function pointers which are actually declared as class derived from System.MulticastDelegate. There are few rules how to write that class. First you must declare .ctor and Invoke methods, if you like to have asynchronous callback involved there are two more methods just for that case BeginInvoke and EndInvoke. Except for these two or four methods nothing else should be declared and these declarations must be without implementation (empty body). This is what it looks like:

    .method public hidebysig specialname rtspecialname 
    instance void .ctor(object 'object',
    native int 'method') runtime managed
    {
    } // end of method WildCard::.ctor

    .method public hidebysig virtual instance int32 
    Invoke() runtime managed
    {
    } // end of method WildCard::Invoke 

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of Exploring Delegates.

Leave a comment

Sign in or Join us (it's free).

AddThis

Related discussion

Related podcasts

  • Looking into the C# Crystal Ball with Charlie Calvert and Bill Wagner

    One of the most exciting announcements from PDC was the news about C# 4.0 and Visual Studio 2010. With all the excitement and discussion throughout the event about these new developer tools, we reached out to two experts in the fields. Charlie Calvert and Bill Wagner sat down with Keith and Woody...

Events coming up

  • Dec 6

    Developing AJAX Web Applications with Castle Monorail

    London, United Kingdom

    Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!