private void Update() { #if UNITY_EDITOR if (Input.GetMouseButtonDown(0)) { OnStart?.Invoke(); } if (Input.GetMouseButtonUp(0)) { OnStop?.Invoke(); } return; #endif if (Input.touches.Length > 0) { if (!_isTouched) { _isTouched = true; OnStart?.Invoke(); } } else { if (_isTouched) { _isTouched = false; OnStop?.Invoke(); } } }
public async void RaiseOnStop() { if (OnStop != null) { await OnStop.Invoke(); } }
static void Main(string[] args) { if (args.Length > 0) { switch (args[0]) { case "i": break; case "u": break; case "t": OnStart += ServiceHelper.Run; OnStop += ServiceHelper.Stop; OnStart?.Invoke(); Console.WriteLine("Started Ok!"); Console.WriteLine("Enter any key to stop."); Console.ReadLine(); OnStop?.Invoke(); break; default: break; } } else { RunAsWinService(); } }
public void StartListener() { if (IsListening) { return; } if (NetworkInterface.GetIsNetworkAvailable()) { tokenSource = new CancellationTokenSource(); CancellationToken cancellationToken = tokenSource.Token; listeningTask = Task.Run(() => { IsListening = true; try { StartListenerAsync(cancellationToken).GetAwaiter().GetResult();; } finally { IsListening = false; OnStop?.Invoke(this, EventArgs.Empty); } }, cancellationToken); } }
private void _ReceiveThread() { try { var isOpen = _isOpen; var buffer = new byte[BufferSize]; var remoteIPEP = (EndPoint) new IPEndPoint(IPAddress.Any, 0); while (isOpen.Value) { var recSize = _socket.ReceiveFrom(buffer, 0, BufferSize, SocketFlags.None, ref remoteIPEP); var packet = new byte[recSize]; Array.Copy(buffer, packet, recSize); OnData?.Invoke((IPEndPoint)remoteIPEP, packet); } } catch (ThreadAbortException) { } catch (Exception ex) { _Cleanup(); OnStop?.Invoke(ex); } }
public void Stop() { _running = false; _halted = false; OnStop?.Invoke(null, null); }
// Stop the server public void Stop() { // Stop the server and release resources _closed = true; try { _tcp.Server.Close(); _tcp.Stop(); } catch (Exception e) { if (Debugger.IsAttached) { Debugger.Break(); } } // Close all open connections _clients.ForEach(x => x.Disconnect()); _clients.Clear(); if (OnStop != null) { OnStop.Invoke(this, null); } }
public virtual void Stop() { if (Disposed) { throw new ObjectDisposedException("Can't call Stop on a disposed object."); } if (!IsListening || Starting || Stopping) { return; } try { Stopping = true; TcpListener.Stop(); TcpListener = null; Stopping = false; OnStop?.Invoke(this); } catch (Exception e) { Logger.LogDebug(e, e.Message); } finally { Stopping = false; } }
protected Resource(MtaResource resource) { resources.Add(resource, this); MtaResource = resource; GameServer.OnStart += (Elements.ResourceRootElement source, Game.Events.OnStartEventArgs eventArgs) => { if (eventArgs.Resource.MtaResource != this.MtaResource) { return; } OnStart?.Invoke(); }; GameServer.OnPreStart += (Elements.ResourceRootElement source, Game.Events.OnPreStartEventArgs eventArgs) => { if (eventArgs.Resource.MtaResource != this.MtaResource) { return; } OnPreStart?.Invoke(); }; GameServer.OnStop += (Elements.ResourceRootElement source, Game.Events.OnStopEventArgs eventArgs) => { if (eventArgs.Resource.MtaResource != this.MtaResource) { return; } OnStop?.Invoke(); }; }
// Stop the server public void Stop() { // Stop the server and release resources _closed = true; try { _tcp.Server.Close(); _tcp.Stop(); } catch (Exception e) { if (Debugger.IsAttached) { Debugger.Break(); } } // Close all open connections foreach (var c in State.Instance.Clients) { c.Disconnect(); } State.Instance.RemoveAllClients(); if (OnStop != null) { OnStop.Invoke(this, null); } }
public void Stop() { if (player != null) { player.Stop(); OnStop?.Invoke(); } }
public GatewayBasedManager(string instance, Dictionary <string, string> config) { Instance = instance; Gateway = GetGateway(instance, config); Gateway.OnDisconnected += delegate(IGateway sender) { OnStop?.Invoke(this); }; Gateway.OnError += delegate(IGateway sender) { OnError?.Invoke(this); }; Gateway.OnReady += delegate(IGateway sender) { OnReady?.Invoke(this); }; }
public void OnStopCallback(int soundId) { TotalTime = TimeSpan.Zero; OnStop?.Invoke(new HowlEventArgs { SoundId = soundId }); }
void StopWithException(Exception ex) { // Synchronously pass the execution exception to the on stop handlers before calling // stop. This is done because stopping processes can trigger other exceptions and // we would like this to be the first one handled. OnStop?.Invoke(ex); Stop(ExitReason.Unknown); }
/// <summary> /// Halts execution /// </summary> /// <param name="raiseEvent"></param> public void Stop(bool raiseEvent = true) { Runner.Stop(); if (raiseEvent) { OnStop?.Invoke(this, EventArgs.Empty); } }
/// <summary> /// 停止服务 /// </summary> public void StopService() { if (apnsBroker != null) { apnsBroker.Stop(); OnStop?.Invoke(apnsBroker); } }
public async Task Stop() { OnStop?.Invoke(this, new EventArgs()); await Scheduler.Shutdown(); await Middleware.Disconnect(); }
public void setDevContainer(Bodyghost.DevContainer devContainer) { int myIndex = this.transform.GetSiblingIndex(); print("Setting devContainer (with serial " + devContainer.serialNumber + ") in frameRelay " + myIndex); this.devContainer = devContainer; OnStop?.Invoke(); streaming = false; }
private void _proc_Exited(object sender, EventArgs e) { _isStart = false; _mw.AppendLogln("INFO", "ffmpeg Exited."); OnStop?.Invoke(this, new DownloaderStopArgs { msg = "Stop" }); }
internal void Stop() { if (!isStopped) { isStopped = true; Die(); OnStop.Invoke(); } }
public void StopPulse() { if (_pulseRoutine != null) { StopCoroutine(_pulseRoutine); } OnStop.Invoke(); }
public void Update() { Fly(); if (_velocity == Vector3.zero) { OnStop?.Invoke(null, EventArgs.Empty); } }
public Task Stop() { var task = new Task(() => { UnifiPollThread?.Abort(); }); task.Start(); OnStop?.Invoke(this); return(task); }
public void StopServer() { _logger.LogDebug($"StopServer: hasProcess: {_process != null}"); AbortBuild(); while (_process != null) { } OnStop?.Invoke(); _logger.LogDebug("StopServer: done"); }
public static async Task ExecuteAsync(TimeSpan time) { OnStart?.Invoke(MODIFICATION_ID); SwapMouseButton(true); await Task.Delay(time).ConfigureAwait(false); SwapMouseButton(false); OnStop?.Invoke(MODIFICATION_ID); }
public void StopFlashLoop() { if (_flashRoutine != null) { StopCoroutine(_flashRoutine); } SetAlphaToDefault(); OnStop.Invoke(); }
public void Stop() { if (!_player.IsPlaying()) { return; } OnStop?.Invoke(); _player.Stop(); }
private void HandleGameStop() { if (!wasStoped) { commands.Enqueue("stop"); wasStoped = true; Console.WriteLine("The game was stopped"); OnStop.Invoke(); } }
/// <summary> /// Stops timer counting and resets time /// </summary> public void Stop() { if (IsRunning()) { IsStopped = true; starter.StopCoroutine(Run()); OnStop?.Invoke(); } }
internal static void Stop(object sender) { Engine.Running = false; //Layer.UpdateRenderEvent.Set(); Layer.PhysicsEvent.Set(); OnStop?.Invoke(); if (!(sender is IWindow window)) { Graphics.Window.Thread?.Abort(); } //Layer.FixedThread?.Abort(); foreach (Layer layer in Layer._Layers) { lock (layer.Groups) { foreach (Group group in layer.Groups) { try { group.Thread.Abort(); } catch (Exception e) { /*#IF DEBUG * Debug.LogException(e); #ENDIF*/ } try { group.PhysicsThread.Abort(); } catch (Exception e) { /*#IF DEBUG * Debug.LogException(e); #ENDIF*/ } } layer.Groups = null; } } Networking.BaseServer[] servers = Networking.BaseServer.Servers.ToArray(); for (int i = 0; i < servers.Length; i++) { servers[i].Delete(); } servers = null; }