Most probably the problem is that your main thread requires invocation. If you would run your program in debugger, you should see the Cross-thread operation exception, but at run time this exception check is disabled.
If your main thread is a form, you can handle it with this short code:
if (InvokeRequired)
{
this.Invoke(new Action(() => MyFunction()));
return;
}
or .NET 2.0
this.Invoke((MethodInvoker) delegate {MyFunction();});
EDIT: for console application you can try following:
var mydelegate = new Action<object>(delegate(object param)
{
Console.WriteLine(param.ToString());
});
mydelegate.Invoke("test");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…