尝试调用委托时c# – “不支持方法”错误

我有一个函数Run(string,string [])我想在一个单独的线程上运行,所以我使用委托和BeginInvoke:

private Func<string, string[], Stack<StackItem>> runner;

public MainPage()
{
    runner = Run;
}

private void btnStep_Click(object sender, RoutedEventArgs e)
{
    // snip
    runner.BeginInvoke(tbCode.Text, GetArgs(), null, null); // Exception here
    // snip
}

private Stack<StackItem> Run(string program, string[] args)
{
    return interpreter.InterpretArgs(parser.Parse(lexer.Analyse(program)), args);
}

但是,我得到NotSupportedException未被用户代码处理,并且委托的BeginInvoke()方法不支持Specified方法的消息.出了什么问题?

我正在使用Silverlight 4.0和VS2010.

解决方法:

异步Delegate.BeginInvoke不适用于Silverlight中的代理.

您应该使用BackgroundWorker instead异步运行任何内容.

相关文章

如何在Silverlight4(XAML)中绑定IsEnabled属性?我试过简单的...
我正在编写我的第一个vb.net应用程序(但我也会在这里标记c#,...
ProcessFile()是在UIThread上运行还是在单独的线程上运行.如...
我从同行那里听说,对sharepoint的了解对职业生涯有益.我们不...
我正在尝试保存一个类我的类对象的集合.我收到一个错误说明:...
我需要根据Silverlight中的某些配置值设置给定控件的Style.我...