Exemple #1
0
        static void Run()
        {
            while (true)
            {
                var mask   = NSEventMask.AnyEvent;
                var @event = NSApplication.SharedApplication.NextEvent(mask, NSDate.DistantFuture, NSRunLoop.NSDefaultRunLoopMode, true);

                if (@event == null)
                {
                    break;
                }

                app.SendEvent(@event);
            }
        }
        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);
        }