Results 1 to 2 of 2

Thread: Using MethodInvoker to pass variables to a method

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2004
    Posts
    26

    Using MethodInvoker to pass variables to a method

    I have been trying to use MethodInvoker to run a method but im not sure how to get the syntax right so it passes a string to the method. As of now I get this error when trying to build: C:\Documents and Settings\Administrator\Desktop\IRCb\frmServer.cs(590): Method 'IRCb.frmServer.RecieveCommand(string)' does not match delegate 'void System.Windows.Forms.MethodInvoker()'

    Code:
    public void RecieveCommand(string Command)
    {
    	Console.WriteLine(Command);
    }
    
    public void InvokeRecieve()
    {
    	MethodInvoker MI = new MethodInvoker(RecieveCommand);
    	this.BeginInvoke(MI);
    }
    Thanks

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: Using MethodInvoker to pass variables to a method

    You can't use parameters with MethodInvoker
    Quote Originally Posted by MSDN
    MethodInvoker provides a simple delegate that is used to invoke a method with a void parameter list. This delegate can be used when making calls to a control's invoke method, or when you need a simple delegate but don't want to define one yourself.
    I think you'll have to make your own delegate.

    Mike

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