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(); } }
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); }