"Method not supported" error when trying to call a delegate

I have a Run(string, string[]) function that I want to run in a separate thread, so I use the delegate and 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); } 

However, I get a NotSupportedException was unhandled by user code with the message Specified method is not supported for the BeginInvoke() method. What's wrong?

I am using Silverlight 4.0 and VS2010.

+4
source share
1 answer

The .BeginInvoke asynchronous delegate is not available to delegates in Silverlight.

Instead, you should use BackgroundWorker to do something asynchronously.

+7
source

All Articles