Example #1
0
 protected virtual void Dispose(bool disposeManagedResources)
 {
     if (!this.disposed && disposeManagedResources)
     {
         if (this.runspace != null)
         {
             this.runspace.Store.Return(this.runspace);
         }
         if (this.executionToken != null)
         {
             this.executionToken.Release();
             this.executionToken = null;
         }
         if (this.timer != null)
         {
             this.timer.Dispose();
             this.timer = null;
         }
         if (this.userCacheLocked)
         {
             DataServiceController.Current.UserDataCache.TryUnlockKey(this.runspace.Borrower);
             this.userCacheLocked = false;
         }
     }
     this.disposed = true;
 }
Example #2
0
        public PipelineInvocation(Envelope <PSRunspace, UserContext> runspace, ResourceType entityType)
        {
            UserData userDatum = null;

            this.runspace                   = runspace;
            this.entityType                 = entityType;
            this.ID                         = Guid.NewGuid();
            this.Status                     = PipelineState.Executing;
            this.WaitMsec                   = 0;
            this.OutputFormat               = null;
            this.ExpirationTime             = DateTimeHelper.UtcNow;
            this.outputQuotaExceeded        = false;
            this.outputObjects              = new PSDataCollection <PSObject>();
            this.Errors                     = new Collection <ErrorRecord>();
            this.finished                   = new ManualResetEvent(false);
            this.TestHookCompletionCallback = new AsyncCallback(this.AsyncCallback);
            if (runspace != null)
            {
                this.executionToken = DataServiceController.Current.GetAuthorizedUserIdentity(runspace.Borrower);
                this.executionToken.AddRef();
                DataServiceController.Current.UserDataCache.TryLockKey(runspace.Borrower, out userDatum);
                this.userCacheLocked = true;
            }
            this.timer = new PswsTimer(new ElapsedEventHandler(this.TimerCallback), DataServiceController.Current.Configuration.PowerShell.Quotas.MaxExecutionTime, false, false);
        }
Example #3
0
 public PSCommand(Envelope <PSRunspace, UserContext> runspace, ResourceType entityType, PSCmdletInfo cmdletInfo, CommandType commandType = (CommandType)1)
 {
     this.syncObject  = new object();
     this.runspace    = runspace;
     this.cmdletInfo  = cmdletInfo;
     this.entityType  = entityType;
     this.parameters  = new Dictionary <string, object>();
     this.powerShell  = null;
     this.timer       = new PswsTimer(new ElapsedEventHandler(this.TimerCallback), DataServiceController.Current.Configuration.PowerShell.Quotas.MaxExecutionTime, false, false);
     this.commandType = commandType;
 }
Example #4
0
 protected virtual void Dispose(bool disposeManagedResources)
 {
     if (!this.disposed && disposeManagedResources)
     {
         if (this.runspace != null)
         {
             this.runspace.Store.Return(this.runspace);
             this.runspace = null;
         }
         if (this.timer != null)
         {
             this.timer.Dispose();
             this.timer = null;
         }
     }
     this.disposed = true;
 }