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 :)
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