Exemple #1
0
        public static async Task <bool> StartDeviceDiscoveryAsync(
            this IBluetoothManager bluetooth, uint timeout, uint delay)
        {
            return(await Task.Run(async() =>
            {
                if (!bluetooth.IsDiscovering)
                {
                    bluetooth.StartDiscovering();

                    for (int i = 0; i *delay < timeout; i++)
                    {
                        if (!bluetooth.IsDiscovering)
                        {
                            await Task.Delay((int)delay);
                        }
                        else
                        {
                            break;
                        }

                        Debug.WriteLine("starting BT discovering...");
                    }
                }

                return bluetooth.IsDiscovering;
            }));
        }