Beispiel #1
0
        public async Task <IAxlResult <bool> > ExecuteAsync(Func <AXLPortClient, Task> execute)
        {
            var result = new AxlResult <bool>();
            var client = this.clientFactory.CreateClient(this.clientSettings);

            try
            {
                await execute(client);

                client.Close();
                result.Value = true;
            }
            catch (CommunicationException exception)
            {
                result.Exception = exception;
                client.Abort();
            }
            catch (TimeoutException exception)
            {
                result.Exception = exception;
                client.Abort();
            }
            catch (Exception exception)
            {
                result.Exception = exception;
                client.Abort();
            }
            return(result);
        }
Beispiel #2
0
        public IAxlResult <TResultValue> Execute <TResultValue>(Func <AXLPortClient, TResultValue> execute)
        {
            var result = new AxlResult <TResultValue>();
            var client = this.clientFactory.CreateClient(this.clientSettings);

            try
            {
                result.Value = execute(client);
                client.Close();
            }
            catch (CommunicationException exception)
            {
                result.Exception = exception;
                client.Abort();
            }
            catch (TimeoutException exception)
            {
                result.Exception = exception;
                client.Abort();
            }
            catch (Exception exception)
            {
                result.Exception = exception;
                client.Abort();
            }
            return(result);
        }