Пример #1
0
        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);
            }
        }
Пример #2
0
 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);
     }
 }
Пример #3
0
        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);
            });
        }
Пример #4
0
 public static unsafe void *CreateNativeCallbackTimer(int dueTime, int period, INativeCallback callback)
 {
     return(AddRefHostObject(new NativeCallbackTimer(dueTime, period, callback)));
 }