Cirrious.MvvmCross.Plugins.Sphero.HackFileShare.NonAwaitingConnectedSpheroRunner.SendCommand C# (CSharp) Method

SendCommand() private method

private SendCommand ( CommandWithActions toSend ) : void
toSend Cirrious.MvvmCross.Plugins.Sphero.Helpers.CommandWithActions
return void
        private void SendCommand(CommandWithActions toSend)
        {
            try
            {
                int sequenceNumber;
                lock (this)
                {
                    sequenceNumber = _sequenceNumber;
                    _sequenceNumber++;

                    _responseListeners[sequenceNumber] = toSend;
                }

                byte[] payload = toSend.Command.GetBytes(sequenceNumber);
                var sendTask = _streamSpheroWrapper.SendBytes(payload);
                sendTask.Start();
                sendTask.Wait();
            }
            catch (AggregateException exception)
            {
                toSend.OnError(exception.InnerException);
            }
            catch (Exception exception)
            {
                toSend.OnError(exception);
            }
        }