Example #1
0
        public void BeginQuery(TimeSpan?timeout = null)
        {
            if (timeout == null)
            {
                timeout = TimeSpan.FromMilliseconds(1500);
            }

            Task.Run(async() =>
            {
                await Task.Delay(timeout.Value);
                lock (this)
                {
                    if (_deviceQueryCompletionSource != null)
                    {
                        Core.PlatformSupport.Services.Logger.LogException("BeginQuery", new Exception("Timeout reading parameter"));
                        _deviceQueryCompletionSource.SetResult(false);
                        _deviceQueryCompletionSource = null;
                    }
                }
            });


            if (_atSettingsReadQueue.Any())
            {
                var atSetting = _atSettingsReadQueue.Dequeue();
                _comms.SendATFrame(atSetting);
            }
            else
            {
                lock (this)
                {
                    _deviceQueryCompletionSource.SetResult(true);
                    _deviceQueryCompletionSource = null;
                }
            }
        }