public NativeCallbackTimer(int dueTime, int period, INativeCallback callback) { this.callback = callback; timer = new Timer(OnTimer, null, Timeout.Infinite, Timeout.Infinite); if ((dueTime != Timeout.Infinite) || (period != Timeout.Infinite)) { timer.Change(dueTime, period); } }
public void Initialize(INativeCallback callback) { try { Callback = callback; App.IsIslandLaunch = true; _app = new App(); } catch (Exception ex) { Debug.WriteLine("Failed to create App2 with " + ex.Message); } }
public static void QueueNativeCallback(INativeCallback callback) { ThreadPool.QueueUserWorkItem(state => { using (callback) { Try(callback.Invoke); } // The above code appears to be problematic on some .NET runtimes, intermittently // triggering premature finalization of the callback. That can lead to a crash if // the callback's finalizer ends up racing against its Dispose method. The call // below should prevent this condition in all cases. GC.KeepAlive(callback); }); }
public static unsafe void *CreateNativeCallbackTimer(int dueTime, int period, INativeCallback callback) { return(AddRefHostObject(new NativeCallbackTimer(dueTime, period, callback))); }