private static CommunicationProcessResult SendInner <T>(Connection connection, IReporter reporter, int timeout, int retryLimit, CommandCallback callback, out T result)
        {
            CommandProcess process = new CommandProcess(connection, reporter, callback, timeout, retryLimit);

            result = default(T);

            CommunicationProcessResult processResult = process.Send();

            if (processResult == CommunicationProcessResult.Success)
            {
                if (callback.ReturnMessage != null &&
                    callback.ReturnMessage.Count > 0 &&
                    callback.ReturnMessage[0] is T)
                {
                    result = (T)callback.ReturnMessage[0];
                }
                else
                {
                    throw new Exception("Command did not return the expected message. " + callback.ReturnMessage.ToString());
                }
            }

            return(processResult);
        }
        /// <summary>
        /// Process a single command synchronously. Note: This method will block until the process is complete.
        /// </summary>
        /// <param name="connection">The connection to use</param>
        /// <param name="reporter">Progress reporter.</param>
        /// <param name="timeout">The timeout in milliseconds.</param>
        /// <param name="retryLimit">The number of retries to try before aborting.</param>
        /// <param name="message">Command OSC message.</param>
        /// <returns>The result of the process.</returns>
        public static CommunicationProcessResult Send(Connection connection, IReporter reporter, int timeout, int retryLimit, OscMessage message)
        {
            CommandProcess process = new CommandProcess(connection, reporter, new CommandCallback(message), timeout, retryLimit);

            return(process.Send());
        }
        /// <summary>
        /// Process a single command synchronously. Note: This method will block until the process is complete.
        /// </summary>
        /// <param name="connection">The connection to use</param>
        /// <param name="reporter">Progress reporter.</param>
        /// <param name="command">Command.</param>
        /// <param name="timeout">The timeout in milliseconds.</param>
        /// <param name="retryLimit">The number of retries to try before aborting.</param>
        /// <param name="args">OSC message arguments</param>
        /// <returns>The result of the process.</returns>
        public static CommunicationProcessResult Send(Connection connection, IReporter reporter, Command command, int timeout, int retryLimit, params object[] args)
        {
            CommandProcess process = new CommandProcess(connection, reporter, new CommandCallback(commandLookup[command].GetMessage(args)), timeout, retryLimit);

            return(process.Send());
        }
        /// <summary>
        /// Process a single command synchronously. Note: This method will block until the process is complete.
        /// </summary>
        /// <param name="connection">The connection to use.</param>
        /// <param name="reporter">Progress reporter.</param>
        /// <param name="command">Command.</param>
        /// <returns>The result of the process.</returns>
        public static CommunicationProcessResult Send(Connection connection, IReporter reporter, Command command)
        {
            CommandProcess process = new CommandProcess(connection, reporter, new CommandCallback(commandLookup[command].Message));

            return(process.Send());
        }