Пример #1
0
        public override void EnterMessageLoop(bool runInBackground)
        {
            NSApplication app = NSApplication.SharedApplication;

            do
            {
                NSEvent evt = null;
                do
                {
                    bool   wait       = !_window.IsKeyWindow && !runInBackground;
                    NSDate expiration = wait ? NSDate.DistantFuture : NSDate.DistantPast;
                    evt = app.NextEvent(NSEventMask.AnyEvent, expiration, NSRunLoopMode.Default, true);

                    if (evt != null)
                    {
                        app.SendEvent(evt);
                    }
                } while (evt != null);

                if (!Closed)
                {
                    OnRender();
                }
            } while (!Closed);
        }
Пример #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);
        }