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); } }
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); } }
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(); } } }
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 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 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); } }
internal void RaiseOnStop(string sender = null, XBMCRPC.Player.OnStop_data data = null) { if (OnStop != null) { OnStop.BeginInvoke(sender, data, null, null); } }
/// <summary> /// 정지 /// </summary> public void Stop() { if (curAudioClip != null) { AudioClipGroup.ErasePlayingClip(curAudioClip); if (m_Data.m_eAudioClipGroup == E_AUDIO_CLIP_GROUP.Stop) { AudioClipGroup.Stop.OnStop(curAudioClip); } else if (m_Data.m_eAudioClipGroup == E_AUDIO_CLIP_GROUP.Bgm_Map) { AudioClipGroup.Bgm_Map.OnStop(curAudioClip); } else if (m_Data.m_eAudioClipGroup == E_AUDIO_CLIP_GROUP.Bgm_Special) { AudioClipGroup.Bgm_Special.OnStop(curAudioClip); } } audioSource.Stop(); Reset(); OnStop.Execute(); }
public async void RaiseOnStop() { if (OnStop != null) { await OnStop.Invoke(); } }
internal void RaiseOnStop(string sender = null, OnStopdataType data = null) { if (OnStop != null) { OnStop.BeginInvoke(sender, data, null, null); } }
/// <summary> /// 停止服务 /// </summary> public void StopService() { if (apnsBroker != null) { apnsBroker.Stop(); OnStop?.Invoke(apnsBroker); } }
/// <summary> /// Halts execution /// </summary> /// <param name="raiseEvent"></param> public void Stop(bool raiseEvent = true) { Runner.Stop(); if (raiseEvent) { OnStop?.Invoke(this, EventArgs.Empty); } }
public async Task Stop() { OnStop?.Invoke(this, new EventArgs()); await Scheduler.Shutdown(); await Middleware.Disconnect(); }
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> /// 终止所有线程,清空待执行任务 /// </summary> public void Stop() { switchTimer(); //这里应该直接压入到已完成队列,而不是清掉 while (AllTaskCount > 0) { T t; if (AllTasks.TryTake(out t)) { if (DoneTasks.TryAdd(t.Id, t) && DoneTasksAdded != null) { DoneTasksAdded.Invoke(this, new TaskArgs(t, this, t.AsyncState)); } } } Task.Factory.StartNew(() => { while (WorkTaskCount > 0) { //给正在执行的线程传入CancelToken Parallel.ForEach(WorkTasks, (x, y) => { if (x.Value.Status == TaskStatus.Canceled || x.Value.Status == TaskStatus.Faulted || x.Value.Status == TaskStatus.RanToCompletion) { DoneTasks.TryAdd(x.Key, x.Value); if (DoneTasksAdded != null) { DoneTasksAdded.Invoke(this, new TaskArgs(x.Value, this, x.Value.AsyncState)); } T t; WorkTasks.TryRemove(x.Key, out t); } else { x.Value.Cancel(); } }); if (OnStoping != null) { OnStoping.BeginInvoke(this, null, null, null); } System.Threading.Thread.Sleep(10); } }).ContinueWith((x) => { if (OnStop != null) { OnStop.BeginInvoke(this, null, null, null); } _isStoped = true; switchTimer(); }); }
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; }
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); } }
private void _proc_Exited(object sender, EventArgs e) { _isStart = false; _mw.AppendLogln("INFO", "ffmpeg Exited."); OnStop?.Invoke(this, new DownloaderStopArgs { msg = "Stop" }); }
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(); }