System.Windows.Threading.Dispatcher.InvokeDelegate C# (CSharp) Method

InvokeDelegate() static private method

static private InvokeDelegate ( Delegate d, object args ) : void
d Delegate
args object
return void
		internal static void InvokeDelegate (Delegate d, object[] args)
		{
			if (d is Action) {
				((Action)d) ();
			}
			else if (d is SendOrPostCallback) {
				((SendOrPostCallback)d) (args[0]);
			}
			else if (d is EventHandler) {
				((EventHandler)d) (args[0], (EventArgs)args[1]);
			}
			else if (d is Deployment.AssemblyRegistration) {
				((Deployment.AssemblyRegistration)d) ((Assembly)args[0]);
			}
			else {
#if DEBUG
				Console.WriteLine ("slow path Dispatcher.InvokeDelegate, delegate type is {0}", d.GetType());
#endif
				d.DynamicInvoke (args);
			}
		}

Usage Example

Beispiel #1
0
 internal void Invoke()
 {
     try {
         Dispatcher.InvokeDelegate(d, args);
     } catch (TargetInvocationException tie) {
         // the unhandled exception is the inner exception, not the TargetInvocationException
         Application.OnUnhandledException(this, tie.InnerException);
     } catch (Exception ex) {
         Application.OnUnhandledException(this, ex);
     }
 }