/// <summary>
 /// Executes the provided <see cref="GpgCommand"/> using the provided input stream        
 /// </summary>
 /// <param name="command">A <see cref="GpgCommand"/> instance to execute.</param>
 /// <param name="output">A <see cref="Stream"/> into which output data will be written, or null
 /// if no output stream is required for the execution of the command.</param>
 public void Execute(GpgCommand command, Stream output)
 {
     Execute(command, null, output, TimeSpan.MaxValue);
 }
 /// <summary>
 /// Executes the provided <see cref="GpgCommand"/>.
 /// </summary>
 /// <param name="command">A <see cref="GpgCommand"/> instance to execute.</param>
 public void Execute(GpgCommand command)
 {
     Execute(command, null, null, TimeSpan.MaxValue);
 }
 private void ExecuteAsync(GpgCommand command, Stream input, Stream output, AsyncResult result)
 {
     try
     {
         Execute(command, input, output);
         result.Complete();
     }
     catch(Exception ex)
     {
         result.Throw(ex);
     }
 }
 /// <summary>
 /// Begins executing the provided <see cref="GpgCommand"/> asynchronously using the 
 /// provided input and output streams.
 /// </summary>
 /// <param name="command">A <see cref="GpgCommand"/> instance to execute.</param>
 /// <param name="input">A <see cref="Stream"/> containing input data, or null if no input stream
 /// is required for the execution of the command.</param>
 /// <param name="output">A <see cref="Stream"/> into which output data will be written, or null
 /// if no output stream is required for the execution of the command.</param>
 /// <param name="callback">An optional asynchronous callback, to be called when 
 /// the execution is complete.</param>
 /// <param name="state">A user-provided object that distinguishes this particular 
 /// asynchronous request from other requests.</param>
 /// <returns></returns>
 public IAsyncResult BeginExecute(GpgCommand command, Stream input, Stream output, AsyncCallback callback, object state)
 {
     var result = new AsyncResult<Stream>(callback, state);
     Task.Factory.StartNew(() => ExecuteAsync(command, input, output, result));
     return result;
 }
 /// <summary>
 /// Executes the provided <see cref="GpgCommand"/> using the provided input and
 /// output streams and the specified timeout value.
 /// </summary>
 /// <param name="command">A <see cref="GpgCommand"/> instance to execute.</param>
 /// <param name="input">A <see cref="Stream"/> containing input data, or null if no input stream
 /// is required for the execution of the command.</param>
 /// <param name="output">A <see cref="Stream"/> into which output data will be written, or null
 /// if no output stream is required for the execution of the command.</param>
 /// <param name="timeout">The amount of time to wait for the command to execute before throwing
 /// an exception.</param>
 public void Execute(GpgCommand command, Stream input, Stream output, TimeSpan timeout)
 {
     var process = new CommandLineProcess(_gpgPath, command.ToString());
     process.Run(input, output, timeout);
 }