private async Task ReceiveSpinner(CancellationToken ct) { while (!ct.IsCancellationRequested) { try { var msg = await ReceiveMessage(ct); await _rxPipeline.Add(msg, ct); } catch (TaskCanceledException) { // Continue, as the next check for the cancelled token is then // performed and the loop is exited. continue; } catch (BrokenFrameException ex) { OnBrokenFrame?.Invoke(this, ex.BrokenFrame, ex.InnerException); } catch (Exception ex) { OnStopped?.Invoke(this, ex); break; } } Running = false; _stream = null; }
public override void Stop() { if (Listener == null) { return; } if (!Listener.Running) { return; } try { Listener?.Stop(); OnStopped?.Invoke(new NetClientEventArgs <ITcpConnection>(this)); } catch (Exception ex) { OnException?.Invoke(new NetClientEventArgs <ITcpConnection>(this) { Exception = ex }); } }
/// <summary>Stops accepting new messages for immediate delivery. </summary> /// <param name="immediate"> /// If <code>true</code>, the service immediately redirects all messages in the queue to the /// backlog; emails that are queued after a stop call are always sent to the backlog. Otherwise, all queued messages /// are sent before closing the producer to additional messages. /// </param> public virtual void Stop(bool immediate = false) { if (!Running) { return; } _buffer.CompleteAdding(); if (!immediate) { WaitForEmptyBuffer(); } else { FlushBacklog(); } Running = false; _uptime.Stop(); if (_internal) { _buffer = new BlockingCollection <T>(); } OnStopped?.Invoke(); }
public void Stop() { browser.Stop(); this.IsBusy = false; OnBusyStatusChange?.Invoke(this.IsBusy, new EventArgs()); OnStopped?.Invoke(this, new EventArgs()); }
/// <summary> /// Stops accepting connections. /// But does not disconnect connected clients. /// In order to disconnect all clients, you need to do it manually /// You can use a ClientContainer implementation to do it easily /// </summary> public void Stop() { IsRunning = false; //stop server time creator timer if (_timeTimer != null) { _timeTimer.Stop(); _timeTimer.Dispose(); _timeTimer = null; } //stop websocket pinger if (Pinger != null) { Pinger.Stop(); Pinger = null; } //stop and dispose all listeners (for all ports) foreach (ConnectionHandler handler in _handlers) { handler.Dispose(); } _handlers.Clear(); OnStopped?.Invoke(this); }
internal override void InvokeEvent(ServerType type, IConnection conn, IMessage msg) { switch (type) { case ServerType.Started: OnStarted?.Invoke(conn, msg); break; case ServerType.Accepted: OnAccepted?.Invoke(conn, msg); break; case ServerType.Sended: OnSended?.Invoke(conn, msg); break; case ServerType.Received: OnRecieved?.Invoke(conn, msg); break; case ServerType.Disconnected: OnDisconnected?.Invoke(conn, msg); break; case ServerType.Stopped: OnStopped?.Invoke(conn, msg); break; } }
public void Stop() { alive = false; acceptor.Abort(); if (listener != null) { listener.Stop(); listener = null; } while (runner.IsAlive) { Thread.Sleep(10); } lock (clientList) { foreach (TcpClient client in clientList) { client.Close(); } } if (OnStopped != null) { OnStopped.Invoke(); } }
public void Stop() { if (!isStart) { return; } isStart = false; OnStopped?.Invoke(); }
private void _stopped() { _worker = null; _cancellationTokenSource?.Dispose(); _cancellationTokenSource = null; Status = WorkerStatus.Stopped; OnStopped?.Invoke(this, new EventArgs()); }
public void StopTimer(bool dispose) { timer.Stop(); counter = 0; OnStopped?.Invoke(); if (dispose) { timer.Dispose(); } }
private void StopMoving() { _state = CubimalState.Settled; _isSettling = false; _navMeshAgent.enabled = false; _animator.SetBool(IsRacingBool, false); _key.StopUnwinding(); _destination = Vector3.zero; OnStopped?.Invoke(); }
public async Task Stop() { await Task <Oridashi.Fhir.Host.Configuration> .Run(new Action(() => { if (host != null) { host.Stop(); } running = false; OnStopped?.Invoke(); })); }
/// <summary> /// Shuts down the client, disconnecting from the IRC server, and shutting down any of our threads. /// </summary> public void Stop() { lock (controlSyncLock) { // Ensure client is killed dead if (client != null) { if (client.IsConnected) { try { client.Disconnect(); } catch (Exception) { } } } if (client != null) { client.Dispose(); client = null; } // Switch status & raise event if we aren't already in stopped state if (Status != ClientStatus.Stopped) { TmiLog.Log("Stopping client..."); if (OnStopped != null) { OnStopped.Invoke(this, new EventArgs()); } } Status = ClientStatus.Stopped; // Kick the queue thread so it quits faster if (channelJoinQueueThread != null) { try { channelJoinQueueThread.Interrupt(); } catch (Exception) { } channelJoinQueueThread = null; } } }
/// <summary> /// Stops the server. /// </summary> public void Stop() { if (running) { lock (runningLock) { if (running) { running = false; ClearRunningState(); OnStopped?.Invoke(this); } } } }
public void Stop() { disconnectPing.Stop(); BroadcastLine(COMMAND_DISCONNECT); Host.Stop(); Host = null; foreach (var client in Clients) { DisconnectClient(client); } Clients.Clear(); InvokeOutput("Server Stopped."); OnStopped?.Invoke(); }
public void Stop() { if (state == UpdatorState.Stop) { return; } state = UpdatorState.Stop; #if UNITY_EDITOR // in case value changed in GameManager maxForceMagnitude = Mathf.Max(1, GameManager.Instance.MaxForce); #endif //force = ForceEvaluator.Evaluate(maxForce, currentScale.x, EvaluateMethod.Parabola); forceMagnitude = ForceEvaluator.Evaluate(maxForceMagnitude, currentScale.x, EvaluateMethod.Linear); OnStopped.Invoke(new StoppedEventArgs(state, currentScale.x, forceMagnitude)); }
public virtual bool Stop() { try { ScheduledTask.StopSchedule(); OnStopped?.Invoke(this, new WorkerStoppedEventArgs()); Store($"{Name} has stopped at {DateTime.Now}"); return(true); } catch (Exception exception) { WorkerLogger.Error("", exception); return(false); } }
private void FixedUpdate() { if (netForceMagnitude <= 0) { OnStopped.Invoke(); hasStopped = true; return; } if (!hasStarted) { OnStarted.Invoke(); hasStarted = true; } AddForce(netForceMagnitude, moveDirection); UpdateNetForce(); }
/// <summary> /// Forces the node to be INACTIVE, bypassing the STOPPING state. /// This is a very dangerous method that can cause unexpected behaviour! /// </summary> /// <param name="success">If the node was successful</param> /// <param name="silent">If true will not invoke the OnStarted event</param> /// <returns></returns> public virtual bool StopNode(bool success, bool silent = false) { if (this.State != NodeState.INACTIVE) { this.State = NodeState.INACTIVE; this.Result = success; if (!silent) { OnStopped.Invoke(success); Parent?.OnChildNodeStopped.Invoke(this, success); } else { OnStoppedSilent.Invoke(success); Parent?.OnChildNodeStoppedSilent.Invoke(this, success); } return(true); } return(false); }
public void SafeWorkerDelegate() { if (_thread == null) { return; } Logger.Debug("Thread {0}: {1} Started", _thread.ManagedThreadId, _thread.Name); while (_working) { try { Thread.Sleep(Math.Max(50, WaitTime)); if (_worker == null) { continue; } if (_worker.Invoke()) { _working = false; } } catch (ThreadAbortException ex) { _working = false; Logger.Debug("Aborting Thread: {0}, StateInfo={1}", _thread.ManagedThreadId, ex.ExceptionState); Thread.ResetAbort(); } catch (Exception ex) { Logger.Log("Error in Thread {0}: {1} {2}", _thread.ManagedThreadId, _thread.Name, ex); } } Logger.Debug("Thread {0}: {1} Finished", _thread.ManagedThreadId, _thread.Name); OnStopped.Invoke(); }
/// <summary> /// 停止NodeServer /// </summary> public Task StopAsync() { if (server == null) { logger.LogDebug("Server instance is not start."); return(Task.CompletedTask); } OnStopping?.Invoke(new NodeServerStopEventArg(config.Host, config.Port, RouteManager.GetAllRoutes())); return(server.CloseAsync().ContinueWith(task => { if (task.Exception != null) { logger.LogError(task.Exception, $"Server closing has error. Host={config.Host}, Port={config.Port}, ExceptionMessage={task.Exception.InnerException.Message}, ExceptionStackTrace={task.Exception.InnerException.StackTrace}"); return; } logger.LogInformation("Server closed"); OnStopped?.Invoke(new NodeServerStopEventArg(config.Host, config.Port, RouteManager.GetAllRoutes())); })); }
public void Stop() { if (IsStopping || !IsStarted) { return; } IsStopping = true; OnStopping?.Invoke(); OnContextStopping?.Invoke(this); IsStopping = false; IsStarted = false; OnStopped?.Invoke(); OnContextStopped?.Invoke(this); DisposeModules(); DisposeExtensions(); }
private void CompletedTask() { while (_run) { try { var activeThread = Active; if (activeThread == 0 && _runnerStatus == RunnerStatus.Stopped) { _run = false; _stopwatch.Stop(); _datapool.Clear(); _cts.Dispose(); try { OnStopped?.Invoke(this, new StopEventArgs() { WordList = _wordlist, Save = _save, Log = _log }); } catch (Exception ex) { OnException?.Invoke(this, new ExceptionEventArgs() { Location = "OnStopped", Exception = ex, Log = _log }); } } else if (activeThread == 0) { _run = false; _stopwatch.Stop(); _datapool.Clear(); _cts.Dispose(); _runnerStatus = RunnerStatus.Completed; try { OnCompleted?.Invoke(this, new EventArgs()); } catch (Exception ex) { OnException?.Invoke(this, new ExceptionEventArgs() { Location = "OnCompleted", Exception = ex, Log = _log }); } } } catch { } Thread.Sleep(100); } }
public void Run(GimmickValue value, DateTime current) { if (playableDirector == null) { return; } if (value.TimeStamp <= LastTriggeredAt) { return; } if (playTimelineGimmick != null && value.TimeStamp <= playTimelineGimmick.LastTriggeredAt) { return; } LastTriggeredAt = value.TimeStamp; playableDirector.time = playableDirector.initialTime; playableDirector.Evaluate(); playableDirector.Stop(); OnStopped?.Invoke(); }
void Instance_CurrentStateChanged(object sender, RoutedEventArgs e) { switch (Instance.CurrentState) { case MediaElementState.Closed: StatusChanged?.Invoke(this, MediaState.NothingSpecial); break; case MediaElementState.Opening: StatusChanged?.Invoke(this, MediaState.Opening); break; case MediaElementState.Buffering: StatusChanged?.Invoke(this, MediaState.Buffering); break; case MediaElementState.Playing: StatusChanged?.Invoke(this, MediaState.Playing); dispatchTimer?.Start(); break; case MediaElementState.Paused: StatusChanged?.Invoke(this, MediaState.Paused); dispatchTimer?.Stop(); break; case MediaElementState.Stopped: StatusChanged?.Invoke(this, MediaState.Stopped); dispatchTimer?.Stop(); OnStopped?.Invoke(this); break; default: throw new ArgumentOutOfRangeException(); } }
public void InvokeOnStopped(int exitCode) { OnStopped?.Invoke(exitCode); }
protected virtual void OnStoppedHandler(TEventArgs args) => OnStopped?.Invoke(args);
/// <summary>Events</summary> public void Event() { RaiseEvent raiseEvent; while (Events.TryDequeue(out raiseEvent)) { // Raise start event if (raiseEvent.EventType == EventType.Started) { OnStarted?.Invoke(); } // Raise stop event if (raiseEvent.EventType == EventType.Stopped) { OnStopped?.Invoke(); } // Raise link event if (raiseEvent.EventType == EventType.Linked) { OnLinked?.Invoke(raiseEvent.Link); } // Raise redirection event if (raiseEvent.EventType == EventType.Redirect) { OnRedirect?.Invoke(raiseEvent.Link); } // Raise post redirection event if (raiseEvent.EventType == EventType.Redirected) { OnRedirected?.Invoke(raiseEvent.Link); } // Raise approval event if (raiseEvent.EventType == EventType.Approval) { OnApproval?.Invoke(raiseEvent.Link, raiseEvent.Content); } // Raise content event if (raiseEvent.EventType == EventType.Content) { OnContent?.Invoke(raiseEvent.Link, raiseEvent.Content); } // Raise unlink event if (raiseEvent.EventType == EventType.Unlinked) { OnUnlinked?.Invoke(raiseEvent.Link, raiseEvent.Reason); } // Raise failure event if (raiseEvent.EventType == EventType.Failed) { OnFailed?.Invoke(raiseEvent.Link, raiseEvent.Failure); } } }
void DataStopped(SDEventArgs args) { OnStopped?.Invoke(args); }
private void CallOnStopped() { OnStopped.Invoke(); }