我有一个函数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异步运行任何内容.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。