Пример #1
0
 // Called from the thread that created this control
 public void InvokeScript(object call1, object call2)
 {
     lock (this)
     {
         ScriptCall scriptCall = call1 as ScriptCall;
         MethodCall methodCall = call2 as MethodCall;
         try
         {
             object rv = WebBrowser.Document.InvokeScript(scriptCall.method, scriptCall.GetScriptingArgs());
             if (methodCall != null && methodCall.method != null)
             {
                 // We may want to invoke a native method as well.  Check to see if the event was handled.
                 bool doInvokeMethod = false;
                 if (rv == null)
                 {
                     doInvokeMethod = true;
                 }
                 else
                 {
                     doInvokeMethod = (bool)rv;
                 }
                 if (doInvokeMethod)
                 {
                     methodCall.method.DynamicInvoke(methodCall.GetMethodArgs());
                     return;
                 }
             }
         }
         catch (Exception e)
         {
             Debug.Assert(false, string.Format("Failed to invoke script: {0} -- {1}", scriptCall, e));
         }
     }
 }
Пример #2
0
 // Called from the worker thread
 internal void AsyncInvokeScript(ScriptCall scriptCall, MethodCall methodCall)
 {
     // If we have a dialog result other than none, we have already returned from
     // the dialog, and have no guarrantee that the dialog is still around.
     try
     {
         this.BeginInvoke(new InvokeHandler(this.InvokeScript), scriptCall, methodCall);
     }
     catch (InvalidOperationException)
     {
         // Guess the dialog wasn't ready -- just ignore
     }
 }
 // Called from the worker thread
 internal void AsyncInvokeScript(ScriptCall scriptCall, MethodCall methodCall)
 {
     // If we have a dialog result other than none, we have already returned from
     // the dialog, and have no guarrantee that the dialog is still around.
     try
     {
         this.BeginInvoke(new InvokeHandler(this.InvokeScript), scriptCall, methodCall);
     }
     catch (InvalidOperationException)
     {
         // Guess the dialog wasn't ready -- just ignore
     }
 }