Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Passing function as argument to c#

$
0
0
Hi Praveen,

The problem is that script functions aren't implicitly convertible to .NET delegates. They do support dynamic invocation, so you can do something like this:
publicvoid LaunchWinForm(dynamic launchAction) {
    if (MainForm.InvokeRequired) {
        MainForm.BeginInvoke(new Action(() => launchAction()), null);
    }
    else {
        launchAction();
    }
}
Good luck!

Viewing all articles
Browse latest Browse all 2297

Trending Articles