Results 1 to 3 of 3

Thread: [RESOLVED] [2.0] Generic Event

Threaded View

  1. #1

    Thread Starter
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Resolved [RESOLVED] [2.0] Generic Event

    Consider this class/delegate:
    Code:
    public delegate void MessageHandler(Message message);
    
    public class CallbackSink : MarshalByRefObject
    {
      public event MessageHandler clientMethod;
    
      [OneWay] public void InvokeClient(Message message)
      {
        if (clientMethod != null)
          clientMethod(message);
      }
    }
    I'd really like to be able to do this:
    Code:
    public class CallbackSink<T> : MarshalByRefObject
    {
      public event T clientMethod;
    
      // ...
    —but it won't let me ("event must be of a delegate type").

    Is it possible at all to make the delegate type generic?

    Cheers

    - P
    Last edited by penagate; Sep 20th, 2007 at 12:41 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width