public void InvokeOnMainLoop (InvokerHelper helper) { var potentialMethods = Application.GetMethods (System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); var invokeOnMainThreadMethod = potentialMethods.First (m => m.Name == "InvokeOnMainThread" && m.GetParameters ().Length == 1); var invoker = Delegate.CreateDelegate (invokeOnMainThreadMethod.GetParameters () [0].ParameterType, helper, "Invoke"); invokeOnMainThreadMethod.Invoke (SharedApplication, new [] { invoker }); }
public void InvokeOnMainLoop (InvokerHelper helper) { var application = Type.GetType ("Xwt.Application, Xwt"); var invokeOnMainThreadMethod = application.GetMethod ("Invoke", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); var invoker = Delegate.CreateDelegate (invokeOnMainThreadMethod.GetParameters () [0].ParameterType, helper, "Invoke"); invokeOnMainThreadMethod.Invoke (null, new [] { invoker }); }
public void InvokeOnMainLoop(InvokerHelper helper) { var potentialMethods = Application.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); var invokeOnMainThreadMethod = potentialMethods.First(m => m.Name == "InvokeOnMainThread" && m.GetParameters().Length == 1); var invoker = Delegate.CreateDelegate(invokeOnMainThreadMethod.GetParameters() [0].ParameterType, helper, "Invoke"); invokeOnMainThreadMethod.Invoke(SharedApplication, new [] { invoker }); }
public void InvokeOnMainLoop(InvokerHelper helper) { var application = Type.GetType("Xwt.Application, Xwt"); var invokeOnMainThreadMethod = application.GetMethod("Invoke", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); var invoker = Delegate.CreateDelegate(invokeOnMainThreadMethod.GetParameters() [0].ParameterType, helper, "Invoke"); invokeOnMainThreadMethod.Invoke(null, new [] { invoker }); }
static void Shutdown() { // Run the shutdown method on the main thread var helper = new InvokerHelper { Func = () => { if (BeforeShutdown != null) { BeforeShutdown(null, EventArgs.Empty); } MainLoop.Shutdown(); return(null); } }; MainLoop.InvokeOnMainLoop(helper); }
static void Shutdown() { // Run the shutdown method on the main thread var helper = new InvokerHelper { Func = () => { try { if (BeforeShutdown != null) { BeforeShutdown(null, EventArgs.Empty); } } catch (Exception ex) { Console.WriteLine("Unexpected error during `BeforeShutdown`: {0}", ex); } finally { MainLoop.Shutdown(); } return(null); } }; MainLoop.InvokeOnMainLoop(helper); }
public void InvokeOnMainLoop(InvokerHelper helper) { NSApplication.SharedApplication.InvokeOnMainThread (helper.Invoke); }
static void Shutdown () { // Run the shutdown method on the main thread var helper = new InvokerHelper { Func = () => { if (BeforeShutdown != null) BeforeShutdown (null, EventArgs.Empty); MainLoop.Shutdown (); return null; } }; MainLoop.InvokeOnMainLoop (helper); }