示例#1
0
        public async Task ScanAsync()
        {
            if (!scanClicked)
            {
                scanClicked = true;
                Debug.WriteLine("Scanning...");
                await Task.Delay(1);

                // Send message
                var sendModels = _ledLibrary.Send(CommonHelpers.DISCOVERY_PORT);
                Debug.WriteLine(sendModels.Status);
                _socket = sendModels.Socket;
                // Receive message
                await Task.Delay(1);

                var progress = new Progress <string>(status => { Debug.WriteLine(status); });
                LoadFoundBulbs(await _ledLibrary.Receive(progress, _socket, CommonHelpers.DISCOVERY_PORT,
                                                         CommonHelpers.TIMEOUT));
                Debug.WriteLine("Ready");
                scanClicked = false;
            }
        }
        private async Task Scan()
        {
            if (!scanClicked)
            {
                scanClicked     = true;
                StatusText.Text = "Scanning...";
                await Task.Delay(1);

                // Send message
                var sendModels = ledLibrary.Send(CommonHelpers.DISCOVERY_PORT);
                StatusText.Text = sendModels.Status;
                socket          = sendModels.Socket;
                // Receive message
                await Task.Delay(1);

                var progress = new Progress <string>(status =>
                {
                    StatusText.Text = status;
                });
                LoadFoundBulbs(await ledLibrary.Receive(progress, socket, CommonHelpers.DISCOVERY_PORT, CommonHelpers.TIMEOUT));
                StatusText.Text = "Ready";
                scanClicked     = false;
            }
        }