コード例 #1
0
        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);
        }
コード例 #2
0
 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");
 }
コード例 #3
0
ファイル: Camera.cs プロジェクト: yourina/TizenFX
 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");
 }
コード例 #4
0
        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.");
        }
コード例 #5
0
ファイル: Radio.cs プロジェクト: younghajung/TizenFX
        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);
        }
コード例 #6
0
 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);
 }
コード例 #7
0
        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();
        }
コード例 #8
0
 private void TeklaObject_Interrupted()
 {
     Interrupted?.Invoke();
 }
コード例 #9
0
 /// <summary>
 ///     Invokes the interrupted delegate.
 /// </summary>
 /// <param name="sender">The sender.</param>
 private void OnInterrupted(ITransport sender)
 => Interrupted?.Invoke(sender);
コード例 #10
0
 void OnInterrupted(object sender, EventArgs e)
 {
     interrupted = true;
     Interrupted?.Invoke(this, e);
 }
コード例 #11
0
ファイル: System.cs プロジェクト: jxpxxzj/boss-Com
 private void Cpu_Interrupted(object sender, InterruptEventArgs e)
 {
     Interrupted?.Invoke(sender, e);
 }
コード例 #12
0
 private void OnInterrupted(object sender, EventArgs e)
 {
     Interrupted?.Invoke(this, e);
 }