HELP: Delegates to interface methods

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sparky74
    New Member
    • Jun 2007
    • 20

    HELP: Delegates to interface methods

    Hi Everyone. I have an interface:

    Code:
    namespace SharedInterfaces
    {
      public interface ICommunicationService
      {
        void SaySomething( String pText );
      }
    }
    What I'm trying to do is implement a wrapper that calls the SaySomething() method on a worker thread which will abort the thread if it takes too long.

    Code:
    public delegate void MyFunc( String s );
    ...
    public ICommunicationService  obj;
    
    obj = ( ICommunicationService ) 
                Activator.GetObject( typeof( ICommunicationService ),
                                     "ipc://IPChannelName/PaulStuff" );
    
    // The below line won't work..
    public MyFunc f = obj.SaySomething;
    Does anybody know how I can get a generic delegate (function pointer) to point to one of my interface methods?

    Thanks
    Paul
Working...