Beispiel #1
0
        // Overridden from BaseAndroidION
        public override void Dispose()
        {
            base.Dispose();
            remoteHandler.RemoveCallbacksAndMessages(null);
            handlerThread.QuitSafely();

            handlerThread = null;
            remoteHandler = null;
        }
Beispiel #2
0
 private void stopBackgroundThread()
 {
     if (backgroundThread != null)
     {
         backgroundThread.QuitSafely();
         backgroundThread  = null;
         backgroundHandler = null;
     }
 }
            public void OnSendFinished(PendingIntent pendingIntent, Intent intent, [GeneratedEnum] Result resultCode, string resultData, Bundle resultExtras)
            {
                var packageManager = _context.PackageManager;

                if (intent.ResolveActivity(packageManager) == null)
                {
                    _fallbackIntent.Send();
                }

                _handlerThread.QuitSafely();
            }
Beispiel #4
0
 private void StopBackgroundThread()
 {
     thread.QuitSafely();
     try
     {
         thread.Join();
         thread            = null;
         backgroundHandler = null;
     } catch (InterruptedException e)
     {
         e.PrintStackTrace();
     }
 }
Beispiel #5
0
 private void StopBackgroundThread()
 {
     mBackgroundThread.QuitSafely();
     try
     {
         mBackgroundThread.Join();
         mBackgroundThread  = null;
         mBackgroundHandler = null;
     }
     catch
     {
     }
 }
Beispiel #6
0
 // Stops the background thread and its {@link Handler}.
 public void Stop()
 {
     _backgroundThread.QuitSafely();
     try
     {
         _backgroundThread.Join();
         _backgroundThread = null;
         Handler           = null;
     }
     catch (InterruptedException e)
     {
         Debug.WriteLine(e);
     }
 }
Beispiel #7
0
 private void Stopbackgroundthread()
 {
     Thread.QuitSafely();
     try
     {
         Thread.Join();
         Thread  = null;
         Handler = null;
     }
     catch
     {
     }
     //throw new NotImplementedException();
 }
Beispiel #8
0
 /// <summary>
 /// Close the camera thread.
 /// </summary>
 public void StopCameraThread()
 {
     mCameraThread.QuitSafely();
     try
     {
         mCameraThread.Join();
         mCameraThread  = null;
         mCameraHandler = null;
     }
     catch (System.Exception e)
     {
         Log.Debug(TAG, "StopCameraThread error");
     }
 }
Beispiel #9
0
 // Stops the background thread and its {@link Handler}.
 public void StopBackgroundThread()
 {
     mBackgroundThread?.QuitSafely();
     try
     {
         mBackgroundThread?.Join();
         mBackgroundThread  = null;
         mBackgroundHandler = null;
     }
     catch (InterruptedException e)
     {
         Crashes.TrackError(e);
         e.PrintStackTrace();
     }
 }
Beispiel #10
0
 /// <summary>
 /// Stops the background thread and its {@link Handler}.
 /// </summary>
 void StopBackgroundThread()
 {
     mBackgroundThread.QuitSafely();
     try
     {
         mBackgroundThread.Join();
         mBackgroundThread = null;
         lock (mCameraStateLock)
         {
             mBackgroundHandler = null;
         }
     }
     catch (Java.Lang.InterruptedException e)
     {
         e.PrintStackTrace();
     }
 }
 /// <summary>
 /// Stops the background thread and its {@link Handler}.
 /// </summary>
 public void StopBackgroundThread()
 {
     if (backgroundThread != null)
     {
         backgroundThread.QuitSafely();
         try
         {
             backgroundThread.Join();
             backgroundThread  = null;
             backgroundHandler = null;
         }
         catch (InterruptedException e)
         {
             e.PrintStackTrace();
         }
     }
 }
        IReadOnlyCollection <BluetoothDeviceInfo> DoDiscoverDevices(int maxDevices)
        {
            List <BluetoothDeviceInfo> devices = new List <BluetoothDeviceInfo>();

            HandlerThread handlerThread = new HandlerThread("ht");

            handlerThread.Start();
            Looper  looper  = handlerThread.Looper;
            Handler handler = new Handler(looper);

            BluetoothDiscoveryReceiver receiver = new BluetoothDiscoveryReceiver();
            IntentFilter filter = new IntentFilter();

            filter.AddAction(BluetoothDevice.ActionFound);
            filter.AddAction(BluetoothAdapter.ActionDiscoveryFinished);
            filter.AddAction(BluetoothAdapter.ActionDiscoveryStarted);
            Platform.CurrentActivity.RegisterReceiver(receiver, filter, null, handler);

            EventWaitHandle handle = new EventWaitHandle(false, EventResetMode.AutoReset);

            receiver.DeviceFound += (s, e) =>
            {
                if (!devices.Contains(e))
                {
                    devices.Add(e);

                    if (devices.Count == maxDevices)
                    {
                        BluetoothAdapter.DefaultAdapter.CancelDiscovery();
                    }
                }
            };

            BluetoothAdapter.DefaultAdapter.StartDiscovery();

            receiver.DiscoveryComplete += (s, e) =>
            {
                Platform.CurrentActivity.UnregisterReceiver(receiver);
                handle.Set();
                handlerThread.QuitSafely();
            };

            handle.WaitOne();

            return(devices.AsReadOnly());
        }
 /** Stops the background thread and its {@link Handler}. */
 private void stopBackgroundThread()
 {
     backgroundThread.QuitSafely();
     try
     {
         backgroundThread.Join();
         backgroundThread  = null;
         backgroundHandler = null;
         lock (@lock)
         {
             runClassifier = false;
         }
     }
     catch (Java.Lang.InterruptedException e)
     {
         Log.Error(TAG, "Interrupted when stopping background thread", e);
     }
 }
Beispiel #14
0
        public void RemoveDisposedInstance()
        {
            using (var t = new HandlerThread("RemoveDisposedInstance")) {
                t.Start();
                using (var h = new Handler(t.Looper)) {
                    var e = new ManualResetEvent(false);
                    Java.Lang.Runnable r = null;
                    r = new Java.Lang.Runnable(() => {
                        e.Set();
                        r.Dispose();
                    });
                    h.Post(r.Run);
                    e.WaitOne();
                }

                t.QuitSafely();
            }
        }
Beispiel #15
0
        private void StopBackgroundThread()
        {
            if (_backgroundThread == null)
            {
                return;
            }

            _backgroundThread.QuitSafely();
            try
            {
                _backgroundThread.Join();
                _backgroundThread      = null;
                this.BackgroundHandler = null;
            }
            catch (InterruptedException ex)
            {
                ex.PrintStackTrace();
            }
        }
        // Stops the background thread and its {@link Handler}.
        private void StopBackgroundThread()
        {
            if (mBackgroundThread == null)
            {
                return;
            }

            mBackgroundThread.QuitSafely();
            try
            {
                mBackgroundThread.Join();
                mBackgroundThread = null;
                BackgroundHandler = null;
            }
            catch (InterruptedException e)
            {
                e.PrintStackTrace();
            }
        }
Beispiel #17
0
        private void StopBackgroundThread()
        {
            if (backgroundThread == null)
            {
                return;
            }

            backgroundThread.QuitSafely();
            try
            {
                backgroundThread.Join();
                backgroundThread  = null;
                backgroundHandler = null;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine($"{e.Message} {e.StackTrace}");
            }
        }
        // Stops the background thread and its {@link Handler}.
        protected void StopBackgroundThread()
        {
            if (_backgroundThread == null)
            {
                return;
            }

            _backgroundThread.QuitSafely();
            try
            {
                _backgroundThread.Join();
                _backgroundThread = null;
                BackgroundHandler = null;
            }
            catch (InterruptedException ex)
            {
#if DEBUG
                ex.PrintStackTrace();
#endif
            }
        }
        /// <summary>
        /// Stops the background thread and its {@link Handler}.
        /// </summary>
        public void StopBackgroundThread()
        {
            try
            {
                if (_backgroundThread != null)
                {
                    _backgroundThread.QuitSafely();
                    _backgroundThread.Join();
                    _backgroundThread = null;
                }

                lock (_cameraStateLock)
                {
                    _backgroundHandler = null;
                }
            }
            catch (Java.Lang.InterruptedException e)
            {
                e.PrintStackTrace();
            }
        }
Beispiel #20
0
        public static void StopCapture()
        {
            if (_camera != null)
            {
                _camera.Close();
                _camera = null;
            }

            if (_captureSession != null)
            {
                _captureSession.Close();
                _captureSession = null;
            }

            if (_backgroundThread != null)
            {
                _backgroundThread.QuitSafely();
                _backgroundThread.Join();
                _backgroundThread  = null;
                _backgroundHandler = null;
            }
        }
 public void Show(Context context)
 {
     if (_showAlarmIntent != null)
     {
         HandlerThread handlerThread = new HandlerThread("Intent sending handler");
         try
         {
             handlerThread.Start();
             Looper looper          = handlerThread.Looper;
             var    finishedHandler = new OnFinished(context, _showAllAlarmsIntent, handlerThread);
             _showAlarmIntent.Send(Result.Ok, finishedHandler, new Handler(looper));
         }
         catch (Exception)
         {
             handlerThread.QuitSafely();
             _showAllAlarmsIntent.Send();
         }
     }
     else
     {
         _showAllAlarmsIntent.Send();
     }
 }
Beispiel #22
0
 public void Release()
 {
     _handlerThread.QuitSafely();
 }