Esempio n. 1
0
        private void OnExiting()
        {
            Exiting?.Invoke(this, EventArgs.Empty);

            _icon.Hide();
            Application.Exit();
        }
Esempio n. 2
0
        private void ThreadAction()
        {
            // Set to highest priority
            // Thread.CurrentThread.Priority = ThreadPriority.Highest;

            //
            while (_isAlive)
            {
                lock (_queue)
                {
                    // Wait for jobs (and still alive)
                    while (_queue.Count == 0 && _isAlive)
                    {
                        Monitor.Wait(_queue);
                    }

                    // Process all jobs
                    while (_queue.Count > 0)
                    {
                        var action = _queue.Dequeue();

                        lock (action)
                        {
                            action(); //
                            Monitor.PulseAll(action);
                        }
                    }
                }
            }

            Exiting?.Invoke();
        }
Esempio n. 3
0
        /// <returns>true to cancel</returns>
        protected virtual bool OnExitRequested()
        {
            if (exitInitiated)
            {
                return(false);
            }

            bool?response = null;

            UpdateThread.Scheduler.Add(delegate { response = Exiting?.Invoke() == true; });

            //wait for a potentially blocking response
            while (!response.HasValue)
            {
                Thread.Sleep(1);
            }

            if (response ?? false)
            {
                return(true);
            }

            Exit();
            return(false);
        }
Esempio n. 4
0
 /// <summary>
 /// Calls the <see cref="onExiting"/> and <see cref="Exiting"/> events, if they are valid.
 /// Prefer <see cref="Exiting"/> if you are programmatically adding event handlers at
 /// runtime. If you are adding event handlers in the Unity Editor, prefer <see
 /// cref="onExiting"/>. If you are waiting for this event in a subclass of StateController,
 /// prefer overriding the <see cref="OnExiting"/> method.
 /// </summary>
 protected virtual void OnExiting()
 {
     if (!skipEvents)
     {
         if (onExiting != null)
         {
             onExiting.Invoke();
         }
         Exiting?.Invoke(this, EventArgs.Empty);
     }
 }
Esempio n. 5
0
        private static void OnExiting(PluginApplicationContext context)
        {
            if (context == null)
            {
                return;
            }

            Exiting?.Invoke(context, EventArgs.Empty);

            //激发当前上下文的“Exiting”事件
            context.RaiseExiting();
        }
Esempio n. 6
0
        internal virtual void OnExiting(IRpcSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            if (!Collection.Contains(session))
            {
                return;
            }

            Exiting?.Invoke(this, new EventArgs <IRpcSession>(session));

            Collection.Remove(session);
        }
Esempio n. 7
0
        /// <summary>
        /// Overloaded. Immediately releases the unmanaged resources used by this object.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (!initialized)
            {
                return;
            }

            Log.Message("");
            Log.Message("-------- Game Shutting Down --------");

            //	wait for server
            //	if it is still running :
            cl.Wait();
            sv.Wait();

            //	call exit event :
            Exiting?.Invoke(this, EventArgs.Empty);

            if (disposing)
            {
                while (modules.Any())
                {
                    var module = modules.Pop();
                    Log.Message("Disposing : {0}", module.GetType().Name);
                    module.Dispose();
                }

                Log.Message("Disposing : Content");
                SafeDispose(ref content);

                Log.Message("Disposing : InputDevice");
                SafeDispose(ref inputDevice);

                Log.Message("Disposing : GraphicsDevice");
                SafeDispose(ref graphicsDevice);

                Log.Message("Disposing : UserStorage");
                SafeDispose(ref userStorage);
            }

            base.Dispose(disposing);

            Log.Message("------------------------------------------");
            Log.Message("");

            ReportActiveComObjects();
        }
Esempio n. 8
0
        /// <summary>
        /// Shuts down the engine, cleaning up resources.
        /// </summary>
        public static void Shutdown(int exitCode = 1)
        {
            if (IsExiting)
            {
                return;
            }

            Logger.Warn("Shutting down...");

            AnalyticsService.EndSession();

            ContentProvider.DeleteDirectory(TempPath);

            IsExiting = true;

            var dataModel = Game.DataModel;

            try
            {
                dataModel.OnClose();
            }
            catch (Exception)
            {
                Logger.Error("DataModel OnClose callback errored.");
            }

            Settings.Save();
            UserSettings.Save();

            Exiting?.Invoke(null, null);

            CancelTokenSource.Cancel();

            Logger.Info("dEngine has been shutdown.");

            Environment.Exit(0);
        }
Esempio n. 9
0
 public virtual void Exit()
 {
     Exiting?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 10
0
 public static bool DoExiting() => Exiting?.Invoke() ?? true;
Esempio n. 11
0
 protected void OnExiting(object sender, EventArgs args)
 {
     Exiting?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 12
0
 private static void Exit(ExitCodes code = ExitCodes.Normal)
 {
     Exiting?.Invoke();
     Environment.Exit((int)code);
 }
Esempio n. 13
0
 protected virtual void OnExiting()
 {
     Exiting?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 14
0
 /// <summary>
 /// Raises an Exiting event. Override this method to add code to handle when the game is exiting.
 /// </summary>
 /// <param name="sender">The Game.</param>
 /// <param name="args">Arguments for the Exiting event.</param>
 protected virtual void OnExiting(object sender, EventArgs args)
 {
     Exiting?.Invoke(this, args);
 }
Esempio n. 15
0
 protected override void OnExiting(object sender, EventArgs args)
 {
     Exiting?.Invoke(this, new EventArgs());
     base.OnExiting(sender, args);
     Process.GetCurrentProcess().Kill();
 }
Esempio n. 16
0
 /// <inheritdoc />
 protected sealed override void InitializeEvents() => LibuiLibrary.uiOnShouldQuit(data =>
 {
     CancelEventArgs args = new CancelEventArgs();
     Exiting?.Invoke(this, args);
     return(!args.Cancel);
 }, IntPtr.Zero);
Esempio n. 17
0
        public Game()
        {
            OpenTK.Graphics.GraphicsContext.ShareContexts = true;
            var window = new GameWindow(1280, 720);

            Window = new Window(window);
            ConstructContext();

            GraphicsDevice          = new GraphicsDevice(this, Context);
            GraphicsDevice.Viewport = new Viewport(window.ClientRectangle);
            window.Context.MakeCurrent(window.WindowInfo);
            window.Context.LoadAll();
            GL.Viewport(window.ClientRectangle);
            //Window.Location = new System.Drawing.Point();
            Mouse = new MouseDevice(window.Mouse);
            engenious.Input.Mouse.UpdateWindow(window);
            window.FocusedChanged += Window_FocusedChanged;
            window.Closing        += delegate(object sender, System.ComponentModel.CancelEventArgs e)
            {
                Exiting?.Invoke(this, new EventArgs());
            };

            gameTime = new GameTime(new TimeSpan(), new TimeSpan());

            window.UpdateFrame += delegate(object sender, FrameEventArgs e)
            {
                Components.Sort();

                gameTime.Update(e.Time);

                Update(gameTime);
            };
            window.RenderFrame += delegate(object sender, FrameEventArgs e)
            {
                ThreadingHelper.RunUIThread();
                GraphicsDevice.Clear(Color.CornflowerBlue);
                Draw(gameTime);

                GraphicsDevice.Present();
            };
            window.Resize += delegate(object sender, EventArgs e)
            {
                GraphicsDevice.Viewport = new Viewport(window.ClientRectangle);
                GL.Viewport(window.ClientRectangle);

                Resized?.Invoke(sender, e);
                OnResize(this, e);
            };
            window.Load += delegate(object sender, EventArgs e)
            {
                Initialize();
                LoadContent();
            };
            window.Closing += delegate(object sender, System.ComponentModel.CancelEventArgs e)
            {
                OnExiting(this, new EventArgs());
            };
            window.KeyPress += delegate(object sender, KeyPressEventArgs e)
            {
                KeyPress?.Invoke(this, e.KeyChar);
            };

            //Window.Context.MakeCurrent(Window.WindowInfo);

            Content    = new engenious.Content.ContentManager(GraphicsDevice);
            Components = new GameComponentCollection();
        }
Esempio n. 18
0
 protected void OnExiting(object source, EventArgs e)
 {
     Exiting?.Invoke(this, e);
 }
Esempio n. 19
0
 private void btnExit_Click(object sender, RoutedEventArgs e)
 {
     Exiting?.Invoke(sender, e);
 }
Esempio n. 20
0
 protected virtual void OnExiting(CancelEventArgs e)
 {
     Exiting?.Invoke(this, e);
 }
Esempio n. 21
0
    ///// Event wrappers /////

    protected virtual void RaiseExiting() => Exiting?.Invoke(this, EventArgs.Empty);