Exemplo n.º 1
0
        public IAsyncResult BeginExecute(string command, Dictionary<string, object> parameters, ExecutionOptions options,
                                         AsyncCallback callback, object asyncState)
        {
            AsyncCommandResult asyncCommandResult = new AsyncCommandResult(command, parameters, options, callback,
                                                                           asyncState);
            Queue.Enqueue(asyncCommandResult);

            return asyncCommandResult;
        }
Exemplo n.º 2
0
        public IAsyncResult BeginExecute(string command, Dictionary <string, object> parameters, ExecutionOptions options,
                                         AsyncCallback callback, object asyncState)
        {
            AsyncCommandResult asyncCommandResult = new AsyncCommandResult(command, parameters, options, callback,
                                                                           asyncState);

            Queue.Enqueue(asyncCommandResult);

            return(asyncCommandResult);
        }
Exemplo n.º 3
0
        public Collection <PSObject> EndExecute(IAsyncResult ar)
        {
            AsyncCommandResult asyncCommandResult = ar as AsyncCommandResult;

            if (null == asyncCommandResult)
            {
                throw new InvalidOperationException("the IAsyncResult provided is not of the appropriate type");
            }

            while (!asyncCommandResult.IsCompleted)
            {
                asyncCommandResult.AsyncWaitHandle.WaitOne(100);
                DoWait();
            }
            return(asyncCommandResult.GetCommandResults());
        }
Exemplo n.º 4
0
 private void ExecuteQueuedCommand(AsyncCommandResult asynResult)
 {
     Collection<PSObject> results = null;
     try
     {
         IEnumerable<ErrorRecord> error = null;
         results = _executor.ExecuteCommand(asynResult.Command, asynResult.Parameters, out error,
                                            asynResult.ExecutionOptions);
         asynResult.SetComplete(results, false, null);
     }
     catch (Exception e)
     {
         asynResult.SetComplete(results, false, e);
     }
 }