예제 #1
0
        public virtual void Restart(Action restartAction, bool useAsync = true)
        {
            if (CanRestart)
            {
                if (useAsync)
                {
                    this.restartAction = restartAction;
                    shouldRestart      = true;
                    Stop();
                }
                else
                {
                    // end modal session
                    app.StopModal();
                    app.EndModalSession(Session);

                    restartAction?.Invoke();

                    // restart new session
                    Session = app.BeginModalSession(NativeWindow);
                    Stopped = false;
                }
            }
            else
            {
                restartAction?.Invoke();
            }
        }
예제 #2
0
        static void RunModalWindow(NSWindow window)
        {
            var session = app.BeginModalSession(window);

            while (true)
            {
                var mask   = NSEventMask.AnyEvent;
                var @event = app.NextEvent(mask, NSDate.DistantFuture, NSRunLoop.NSDefaultRunLoopMode, true);

                if (@event != null)
                {
                    app.SendEvent(@event);

                    if (!window.IsVisible)
                    {
                        break;
                    }
                }
            }
            app.EndModalSession(session);
        }