public byte[] AddCommandToQueueAndWaitExecution(IAddressedSendingItem item)
        {
            ISendResult result = new SendingResult(null, null, item);
            var         eve    = new AutoResetEvent(false);
            var         qItem  = new QueueItem {
                SendingItems = new List <IAddressedSendingItem> {
                    item
                },
                OnComplete = results => {
                    result = results.Count == 1
            ? results[0]
            : new SendingResult(null, new Exception("Something wrong with channelSimple"), item);
                    Log.Log("Установка сигнала для ожидающего потока...");
                    eve.Set();
                    Log.Log("Сигнал для ожидающего потока был установлен");
                }
            };

            AddCommandToQueueAndExecuteAsync(qItem);
            Log.Log("Ожидание сигнала от потока выполнения команд...");
            eve.WaitOne();
            Log.Log("Сигнал был установлен потоком выполнения команд");
            if (result.ChannelException != null)
            {
                Log.Log("В результате обмена было создано исключение, сейчас оно будет выброшено");
                throw result.ChannelException;
            }

            return(result.Bytes);
        }
 public SendingResultWithAddress(byte[] bytes, Exception channelException, IAddressedSendingItem request,
                                 ushort addressInReply)
 {
     Bytes            = bytes;
     ChannelException = channelException;
     Request          = request;
     AddressInReply   = addressInReply;
 }
 public SendingResult(byte[] bytes, Exception channelException, IAddressedSendingItem request)
 {
     Bytes            = bytes;
     ChannelException = channelException;
     Request          = request;
 }