private void OnExiting() { Exiting?.Invoke(this, EventArgs.Empty); _icon.Hide(); Application.Exit(); }
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(); }
/// <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); }
/// <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); } }
private static void OnExiting(PluginApplicationContext context) { if (context == null) { return; } Exiting?.Invoke(context, EventArgs.Empty); //激发当前上下文的“Exiting”事件 context.RaiseExiting(); }
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); }
/// <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(); }
/// <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); }
public virtual void Exit() { Exiting?.Invoke(this, EventArgs.Empty); }
public static bool DoExiting() => Exiting?.Invoke() ?? true;
protected void OnExiting(object sender, EventArgs args) { Exiting?.Invoke(this, EventArgs.Empty); }
private static void Exit(ExitCodes code = ExitCodes.Normal) { Exiting?.Invoke(); Environment.Exit((int)code); }
protected virtual void OnExiting() { Exiting?.Invoke(this, EventArgs.Empty); }
/// <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); }
protected override void OnExiting(object sender, EventArgs args) { Exiting?.Invoke(this, new EventArgs()); base.OnExiting(sender, args); Process.GetCurrentProcess().Kill(); }
/// <inheritdoc /> protected sealed override void InitializeEvents() => LibuiLibrary.uiOnShouldQuit(data => { CancelEventArgs args = new CancelEventArgs(); Exiting?.Invoke(this, args); return(!args.Cancel); }, IntPtr.Zero);
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(); }
protected void OnExiting(object source, EventArgs e) { Exiting?.Invoke(this, e); }
private void btnExit_Click(object sender, RoutedEventArgs e) { Exiting?.Invoke(sender, e); }
protected virtual void OnExiting(CancelEventArgs e) { Exiting?.Invoke(this, e); }
///// Event wrappers ///// protected virtual void RaiseExiting() => Exiting?.Invoke(this, EventArgs.Empty);