Exemplo n.º 1
0
        public async Task <string> SendAsync(string messageToSend)
        {
            await SendLock.WaitAsync();

            try
            {
                CommunicationLog.RawMessageSending(messageToSend);
                await SendAsync(ClientWriter, messageToSend);

                CommunicationLog.RawMessageSent(messageToSend);

                do
                {
                    if (MessageResponses.TryDequeue(out var result))
                    {
                        return(result);
                    }

                    await Task.Delay(TimeSpan.FromMilliseconds(10)).ConfigureAwait(false);
                } while (Connected);

                return(null);
            }
            finally
            {
                SendLock.Release();
            }
        }