Cheesebaron.MvxPlugins.Connectivity.Droid.Wifi.GetAllWifiInfoAsync C# (CSharp) Method

GetAllWifiInfoAsync() public method

public GetAllWifiInfoAsync ( CancellationToken token = default(CancellationToken) ) : Task>
token System.Threading.CancellationToken
return Task>
        public Task<IEnumerable<WifiInfo>> GetAllWifiInfoAsync(
            CancellationToken token = default(CancellationToken))
        {
            if (_manager == null)
                throw new InvalidOperationException("WifiManager not initialized");

            _semaphoreSlim.Wait(token);

            var tcs = new TaskCompletionSource<IEnumerable<WifiInfo>>();

            ScanResultReceiver.WifiManager = _manager;
            ScanResultReceiver.OnScanResult = infos =>
            {
                tcs.TrySetResult(infos);
                _semaphoreSlim.Release();
                ScanResultReceiver.OnScanResult = null;
                ScanResultReceiver.WifiManager = null;
            };

            _manager.StartScan();

            return tcs.Task;
        }