public void Interrupte() { // 已中断退出 if (Interlocked.Exchange(ref interrupting, 1) == 1) { return; } Console.WriteLine("interrupted."); try { if (stream == null) { using (Socket) Socket.Shutdown(SocketShutdown.Both); } else { using (stream) { stream.Flush(); } } } catch (SocketException) { } catch (IOException) { } catch (ObjectDisposedException) { } Interrupted?.Invoke(this, EventArgs.Empty); }
private void RegisterInterruptedEvent() { _interruptedCallback = (policy, previousState, currentState, _) => { Interrupted?.Invoke(this, new RecorderInterruptedEventArgs(policy, previousState, currentState)); }; Native.SetInterruptedCallback(_handle, _interruptedCallback, IntPtr.Zero). ThrowIfError("Failed to initialize Interrupted event"); }
private void RegisterInterruptedCallback() { _interruptedCallback = (CameraPolicy policy, CameraState previous, CameraState current, IntPtr userData) => { Interrupted?.Invoke(this, new CameraInterruptedEventArgs(policy, previous, current)); }; CameraErrorFactory.ThrowIfError(Native.SetInterruptedCallback(_handle, _interruptedCallback, IntPtr.Zero), "Failed to set interrupt callback"); }
private void RegisterInterruptedCallback() { _interruptedCallback = (policy, previous, current, _) => { Interrupted?.Invoke(this, new CameraInterruptedEventArgs(policy, previous, current)); }; Native.SetInterruptedCallback(_handle, _interruptedCallback). ThrowIfFailed("Failed to set interrupt callback."); }
private void InitCallbacks() { _scanCompletedCallback = _ => ScanCompleted?.Invoke(this, EventArgs.Empty); _interruptedCallback = (reason, _) => Interrupted?.Invoke(this, new RadioInterruptedEventArgs(reason)); _scanUpdatedCallback = (frequency, _) => ScanUpdated?.Invoke(this, new ScanUpdatedEventArgs(frequency)); _scanStoppedCallback = _ => ScanStopped?.Invoke(this, EventArgs.Empty); }
private void irqPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args) { if (args.Edge != GpioPinEdge.FallingEdge) { return; } _logger.Trace("IRQ Event Received!"); RegisterContainer.StatusRegister.Load(); Interrupted?.Invoke(this, new InterruptedEventArgs { StatusRegister = RegisterContainer.StatusRegister }); _irqPin.Write(GpioPinValue.High); }
public void Run() { if (rcThread != null) { throw new InvalidOperationException("Thread cannot be run twice"); } rcThread = new Thread(() => { unsafe { int err = 0; Exception eObj = null; try { rcPtr = Marshal.AllocHGlobal(sizeof(S2ReceiverContext)); err = SnvBackend.ReceiverThread((S2ReceiverContext *)rcPtr, recvPort, 0, callback); } catch (ThreadAbortException) { } catch (Exception e) { eObj = e; } finally { AppTools.TryInvoke(() => { Interrupted?.Invoke(this, new ReceiverInterruptedEventArgs(err, eObj)); }); Marshal.FreeHGlobal(rcPtr); rcPtr = IntPtr.Zero; rcThread = null; } } }); rcThread.IsBackground = true; rcThread.Start(); }
private void TeklaObject_Interrupted() { Interrupted?.Invoke(); }
/// <summary> /// Invokes the interrupted delegate. /// </summary> /// <param name="sender">The sender.</param> private void OnInterrupted(ITransport sender) => Interrupted?.Invoke(sender);
void OnInterrupted(object sender, EventArgs e) { interrupted = true; Interrupted?.Invoke(this, e); }
private void Cpu_Interrupted(object sender, InterruptEventArgs e) { Interrupted?.Invoke(sender, e); }
private void OnInterrupted(object sender, EventArgs e) { Interrupted?.Invoke(this, e); }