public IAsyncResult BeginServiceDiscovery(BluetoothAddress address, Guid serviceGuid, SdpSearchScope searchScope, AsyncCallback asyncCallback, Object state) { BeginServiceDiscoveryKillInquiry(); // Just in case the user modifies the original address!!! BluetoothAddress addr2 = (BluetoothAddress)address.Clone(); AsyncResult <ISdpDiscoveryRecordsBuffer, ServiceDiscoveryParams> ar = new AsyncResult <ISdpDiscoveryRecordsBuffer, ServiceDiscoveryParams>(asyncCallback, state, new ServiceDiscoveryParams(addr2, serviceGuid, searchScope)); lock (lockServiceDiscovery) { if (m_arServiceDiscovery != null) { throw new NotSupportedException("Currently support only one concurrent Service Lookup operation."); } bool success = false; try { m_arServiceDiscovery = ar; bool ret = m_btIf.StartDiscovery(addr2, serviceGuid); Debug.WriteLine(WidcommUtils.GetTime4Log() + ": StartDiscovery ret: " + ret); if (!ret) { WBtRc ee = GetExtendedError(); throw WidcommSocketExceptions.Create_StartDiscovery(ee); } success = true; } finally { if (!success) { m_arServiceDiscovery = null; } } } return(ar); }
//-- #if !HIDE_WIDCOMM_WIDCOMM_EXCEPTIONS internal static SocketException Create_StartDiscovery(WBtRc ee) { return(CommonSocketExceptions.Create_NoResultCode(CommonSocketExceptions.SocketError_StartDiscovery_Failed, "StartDiscoverySDP" + ((ee == unchecked ((WBtRc)(-1)) /*|| ee == WBtRc.WBT_SUCCESS*/) ? string.Empty : string.Format(System.Globalization.CultureInfo.InvariantCulture, ", {0} = 0x{1:X}", ee, (uint)ee)))); }