private void StartReceiveThread()
        {
            _receiveTaskCancelTokenSource = new CancellationTokenSource();

            Task.Run(async() =>
            {
                try
                {
                    while (_isConnected)
                    {
                        switch (_simulator.DefaultTransport.Value)
                        {
                        case TransportTypes.TCP:
                            {
                                var response = await _tcpClient.ReceiveAsync();
                                await AddReceviedMessage(new ReceivedMessage(response));
                            }

                            break;

                        case TransportTypes.UDP:
                            {
                                var response = await _udpClient.ReceiveAsync();
                                await AddReceviedMessage(new ReceivedMessage(response));
                            }
                            break;
                        }
                    }
                }
                catch (TaskCanceledException) { }
            }, _receiveTaskCancelTokenSource.Token);
        }
Exemplo n.º 2
0
        private void StartReceiveThread()
        {
            Task.Run(async() =>
            {
                while (_isConnected)
                {
                    switch (Model.DefaultTransport.Value)
                    {
                    case TransportTypes.TCP:
                        {
                            var response = await _tcpClient.ReceiveAsync();
                        }

                        break;

                    case TransportTypes.UDP:
                        {
                            var response = await _udpClient.ReceiveAsync();
                        }
                        break;
                    }
                }
            });
        }