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

New Post: Passing function as argument to c#

$
0
0
Hi,

I am trying to pass java script function as parameter to c# function. I implement this using action delegate but throws invalid arguments exception.
public class ScriptFunctions
{
        ..//MainForm property

        public void LaunchWinForm(Action launcAction)
        {
            try
            {
                if (MainForm.InvokeRequired)
                {
                   MainForm.Invoke(new MethodInvoker(launcAction)), null);
                }
                else
                    launcAction)();
            }
            catch (Exception)
            {                
                throw;
            }
        }
}

v8TriggerEngine.AddHostObject("ScriptLib", new ScriptFunctions());
from javscript
var form=new WinForms.System.Windows.Forms.Form();

var delconncect=_fileWatcher.Created.connect(function(obj,e){
     ScriptLib.LaunchWinForm(function(){
                  form.Show();  
     }); 
});
Engine throws invalid argument exception.

Thanks and Regards
Praveen Kumar

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images