/// <summary> /// Raises the <see cref="E:InTheHand.Net.Bluetooth.BluetoothComponent.DiscoverDevicesProgress"/> event. /// </summary> /// <param name="e">A <see cref="T:InTheHand.Net.Bluetooth.DiscoverDevicesEventArgs"/> /// object that contains event data. /// </param> protected void OnDiscoveryProgress(DiscoverDevicesEventArgs e) { var eh = DiscoverDevicesProgress; if (eh != null) { eh(this, e); } }
protected void OnDiscoveryComplete(DiscoverDevicesEventArgs e) { EventHandler <DiscoverDevicesEventArgs> eh = DiscoverDevicesComplete; if (eh != null) { eh(this, e); } }
private void DoRemembered(bool authenticated, bool remembered, bool discoverableOnly, AsyncOperation asyncOp) { if ((authenticated || remembered) && !discoverableOnly) { var rmbd = m_cli.DiscoverDevices(255, authenticated, remembered, false, false); if (rmbd.Length != 0) { var e = new DiscoverDevicesEventArgs(rmbd, asyncOp.UserSuppliedState); SendOrPostCallback cb = delegate(object args) { OnDiscoveryProgress((DiscoverDevicesEventArgs)args); }; asyncOp.Post(cb, e); } } }
private void HandleDiscoNewDevice(InTheHand.Net.Bluetooth.Factory.IBluetoothDeviceInfo newDevice, object state) { Debug.WriteLine(DateTime.UtcNow.TimeOfDay.ToString() + ": HandleDiscoNewDevice."); AsyncOperation asyncOp = (AsyncOperation)state; Debug.Assert(newDevice != null); var rslt = new BluetoothDeviceInfo[] { new BluetoothDeviceInfo(newDevice) }; Debug.Assert(rslt.Length > 0, "NOT rslt.Length > 0"); var e = new DiscoverDevicesEventArgs(rslt, asyncOp.UserSuppliedState); SendOrPostCallback cb = delegate(object args) { OnDiscoveryProgress((DiscoverDevicesEventArgs)args); }; asyncOp.Post(cb, e); }
private void HandleDiscoComplete(IAsyncResult ar) { AsyncOperation asyncOp = (AsyncOperation)ar.AsyncState; DiscoverDevicesEventArgs e; try { #if PRE_V2_4 FuncDiscoDevs dlgt = Interlocked.Exchange(ref m_dlgt, null); BluetoothDeviceInfo[] arr = dlgt.EndInvoke(ar); #else BluetoothDeviceInfo[] arr = m_cli.EndDiscoverDevices(ar); #endif e = new DiscoverDevicesEventArgs(arr, asyncOp.UserSuppliedState); } catch (Exception ex) { e = new DiscoverDevicesEventArgs(ex, asyncOp.UserSuppliedState); // TO-DO ?? Set Cancelled if disposed? } // SendOrPostCallback cb = delegate(object args) { OnDiscoveryComplete((DiscoverDevicesEventArgs)args); }; asyncOp.PostOperationCompleted(cb, e); }