internal override void Run() { Debug.Assert(InitCallback != null, $"{nameof(InitCallback)} is null"); Debug.Assert(RunCallback != null, $"{nameof(RunCallback)} is null"); // Initialize the init callback InitCallback(); var runCallback = new SDLMessageLoop.RenderCallback(RunCallback); // Run the rendering loop try { SDLMessageLoop.Run(window, () => { if (Exiting) { Destroy(); return; } runCallback(); }); } finally { ExitCallback?.Invoke(); } }
internal override void Run() { if (swapChainPanel != null) { CompositionTarget.Rendering += CompositionTarget_Rendering; return; } // Call InitCallback only first time if (InitCallback != null) { InitCallback(); InitCallback = null; } try { while (true) { coreWindow.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent); if (Exiting) { Destroy(); break; } RunCallback(); } } finally { ExitCallback?.Invoke(); } }
internal ExitCallback _exitCallbacks; // callback dissociated from the system so executed even if the system is paused internal Family(Matcher[] matchers) { _gameObjectIdToCacheId = new Dictionary <int, int>(); _cashedGameObjects = new List <GameObject>(); _count = 0; _matchers = matchers; _entryCallbacks = null; _exitCallbacks = null; }
public void SetExitHandler() { var called = false; var exitCb = new ExitCallback(() => { called = true; }); _libVLC.SetExitHandler(exitCb); _libVLC.Dispose(); Assert.IsTrue(called); }
/// <summary> /// <para>Registers a callback for the LibVLC exit event. This is mostly useful if</para> /// <para>the VLC playlist and/or at least one interface are started with</para> /// <para>libvlc_playlist_play() or libvlc_add_intf() respectively.</para> /// <para>Typically, this function will wake up your application main loop (from</para> /// <para>another thread).</para> /// </summary> /// <param name="cb"> /// <para>callback to invoke when LibVLC wants to exit,</para> /// <para>or NULL to disable the exit handler (as by default)</para> /// </param> /// <remarks> /// <para>This function should be called before the playlist or interface are</para> /// <para>started. Otherwise, there is a small race condition: the exit event could</para> /// <para>be raised before the handler is registered.</para> /// <para>This function and libvlc_wait() cannot be used at the same time.</para> /// </remarks> public void SetExitHandler(ExitCallback cb) { _exitCallback = cb; if (cb == null) { Native.LibVLCSetExitHandler(NativeReference, IntPtr.Zero, IntPtr.Zero); } else { Native.LibVLCSetExitHandler( NativeReference, Marshal.GetFunctionPointerForDelegate(ExitCallbackHandle), GCHandle.ToIntPtr(_gcHandle)); } }
public void SetExitHandler() { var instance = new Instance(); var called = false; var exitCb = new ExitCallback(() => { called = true; }); instance.SetExitHandler(exitCb, IntPtr.Zero); instance.Dispose(); Assert.IsTrue(called); }
public void SetExitHandler() { var libVLC = new LibVLC(); var called = false; var exitCb = new ExitCallback(() => { called = true; }); libVLC.SetExitHandler(exitCb, IntPtr.Zero); libVLC.Dispose(); Assert.IsTrue(called); }
internal override void Run() { Debug.Assert(InitCallback != null, $"{nameof(InitCallback)} is null"); Debug.Assert(RunCallback != null, $"{nameof(RunCallback)} is null"); // Initialize the init callback InitCallback(); Debug.Assert(GameContext is GameContextWinforms, "There is only one possible descendant of GameContext<Control>."); var context = (GameContextWinforms)GameContext; if (context.IsUserManagingRun) { context.RunCallback = RunCallback; context.ExitCallback = ExitCallback; } else { var runCallback = new WindowsMessageLoop.RenderCallback(RunCallback); // Run the rendering loop try { WindowsMessageLoop.Run(Control, () => { if (Exiting) { Destroy(); return; } runCallback(); }); } finally { ExitCallback?.Invoke(); } } }
internal override void Run() { Debug.Assert(InitCallback != null, $"{nameof(InitCallback)} is null"); Debug.Assert(RunCallback != null, $"{nameof(RunCallback)} is null"); // Initialize the init callback InitCallback(); var context = (GameContextSDL)GameContext; if (context.IsUserManagingRun) { context.RunCallback = RunCallback; context.ExitCallback = ExitCallback; } else { var runCallback = new SDLMessageLoop.RenderCallback(RunCallback); // Run the rendering loop try { SDLMessageLoop.Run(window, () => { if (Exiting) { Destroy(); return; } runCallback(); }); } finally { ExitCallback?.Invoke(); } } }
/// <summary> /// Adds callback function which will be executed when an exit occurs in this <see cref="FYFY.Family"/>. /// </summary> /// <param name="callback"> /// Callback function. /// </param> public void addExitCallback(ExitCallback callback) { _exitCallbacks += callback; }
public override void Step(GameBoard board) { ConsoleUtil.WriteBlanks(); Console.SetCursorPosition(0, Console.WindowHeight / 2); Console.WriteLine(board.WhiteToMove ? "White to move! Press any key to continue..." : "Black to move! Press any key to continue..."); Console.ReadKey(); var layer = board.WhiteToMove ? GameBoard.BoardType.WhiteShips : GameBoard.BoardType.BlackShips; bool horizontal = true; int length = board.ShipCounts .Where(s => board.CountShipsWithSize(board.Board[(int)layer], s.Key) < s.Value) .Max(s => s.Key); do { bool choosing = true; while (choosing) { ConsoleUtil.WriteBlanks(); _renderer.RenderShips(board.Board[(int)layer], length, horizontal); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\nUse G to autogenerate board instead!"); Console.WriteLine("Use R to revert move"); Console.Write("Press Q to quit!"); var input = Console.ReadKey(); switch (input.Key) { case ConsoleKey.UpArrow: _renderer.HighlightY = Math.Max(0, _renderer.HighlightY - 1); break; case ConsoleKey.DownArrow: _renderer.HighlightY = Math.Min(board.Height - (horizontal ? 1 : length), _renderer.HighlightY + 1); break; case ConsoleKey.RightArrow: _renderer.HighlightX = Math.Min(board.Width - (horizontal ? length : 1), _renderer.HighlightX + 1); break; case ConsoleKey.LeftArrow: _renderer.HighlightX = Math.Max(0, _renderer.HighlightX - 1); break; case ConsoleKey.Enter: choosing = false; break; case ConsoleKey.Spacebar: horizontal = !horizontal; _renderer.HighlightX = Math.Min(board.Width - (horizontal ? length : 1), _renderer.HighlightX); _renderer.HighlightY = Math.Min(board.Height - (horizontal ? 1 : length), _renderer.HighlightY); break; case ConsoleKey.Q: ExitCallback?.Invoke(); return; case ConsoleKey.G: int n = 0; while (n < 10 || !board.GenerateBoard()) { n++; } return; case ConsoleKey.R: board.RevertMove(); return; } } } while (!PlaceShipCallback?.Invoke(_renderer.HighlightY, _renderer.HighlightX, length, horizontal) ?? true); _renderer.HighlightX = 0; _renderer.HighlightY = 0; }
/// <summary> /// <para>Registers a callback for the LibVLC exit event. This is mostly useful if</para> /// <para>the VLC playlist and/or at least one interface are started with</para> /// <para>libvlc_playlist_play() or libvlc_add_intf() respectively.</para> /// <para>Typically, this function will wake up your application main loop (from</para> /// <para>another thread).</para> /// </summary> /// <param name="cb"> /// <para>callback to invoke when LibVLC wants to exit,</para> /// <para>or NULL to disable the exit handler (as by default)</para> /// </param> /// <param name="opaque">data pointer for the callback</param> /// <remarks> /// <para>This function should be called before the playlist or interface are</para> /// <para>started. Otherwise, there is a small race condition: the exit event could</para> /// <para>be raised before the handler is registered.</para> /// <para>This function and libvlc_wait() cannot be used at the same time.</para> /// </remarks> public void SetExitHandler(ExitCallback cb, IntPtr opaque) { var cbFunctionPointer = cb == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(cb); Native.LibVLCSetExitHandler(NativeReference, cbFunctionPointer, opaque); }
private void Exit() { Menu.Close(); ExitCallback?.Invoke(); }
public void SetExitCallBack(ExitCallback ec) { this.exitCallback = ec; }
public static void OpenUI(ENUM_TRAIN_TYPE type = ENUM_TRAIN_TYPE.None, Monster mon = null, ExitCallback callback = null) { if (_mInstanece == null) { Object prefab = PrefabLoader.loadFromPack("ZQ/TrainingRoomUI"); if (prefab != null) { GameObject obj = Instantiate(prefab) as GameObject; RED.AddChild(obj, DBUIController.mDBUIInstance._bottomRoot); _mInstanece = obj.GetComponent <TrainingRoomUI> (); _mInstanece.m_nType = type; _mInstanece.m_monster = mon; } } else { _mInstanece.InitUI(type, mon); _mInstanece.SetShow(true); } _mInstanece.m_callBack = callback; }
private void Exit() { ExitCallback dele = new ExitCallback(Close); this.Invoke(dele); }