Exemplo n.º 1
0
 internal async Task <TRESULT> SendCommandAsync <TRESULT>(CancellationToken token, IWasherCommand <TRESULT> command, int timeout)
 {
     return(await SendCommandAsync(token, _io, command, timeout));
 }
Exemplo n.º 2
0
        private async Task <TRESULT> SendCommandAsync <TRESULT>(CancellationToken token, IOManager iomanager, IWasherCommand <TRESULT> command, int timeout = 10000, int tryCount = 3)
        {
            if (iomanager == null)
            {
                throw new CommandException("No connection");
            }

            do
            {
                token.ThrowIfCancellationRequested();
                try
                {
                    var responce = await iomanager.SendAsync(token, command.GetRequest(), timeout);

                    return(command.ParceResponse(responce));
                }
                catch (TimeoutException e)
                {
                    if (--tryCount <= 0)
                    {
                        throw e;
                    }
                }
            }while (tryCount > 0);

            throw new TimeoutException($"No answer at {timeout} ms");
        }
Exemplo n.º 3
0
 internal async Task SendCommandAsync(CancellationToken token, IWasherCommand command, int timeout)
 {
     await SendCommandAsync(token, _io, command, timeout);
 }