// Token: 0x060012B2 RID: 4786 RVA: 0x0003C778 File Offset: 0x0003A978
        internal void StartRunspace(AuthZPluginUserToken userToken)
        {
            string runspaceCacheKey = this.GetRunspaceCacheKey(userToken);

            if (string.IsNullOrEmpty(runspaceCacheKey))
            {
                AuthZLogger.SafeAppendGenericError("NullOrEmptyRunspaceCacheKey", "User token have an empty ExecutingUserName", false);
                return;
            }
            lock (base.InstanceLock)
            {
                RunspaceCacheValue runspaceCacheValue;
                if (this.runspaceCache.TryGetValue(runspaceCacheKey, out runspaceCacheValue))
                {
                    ExTraceGlobals.PublicPluginAPITracer.TraceDebug <string>((long)this.GetHashCode(), "[PswsBudgetManager.StartRunspace] item {0} is removed explicitly", runspaceCacheKey);
                    if (runspaceCacheValue != null && runspaceCacheValue.CostHandle != null)
                    {
                        runspaceCacheValue.CostHandle.Dispose();
                    }
                    this.runspaceCache.Remove(runspaceCacheKey);
                }
                CostHandle         costHandle = this.StartRunspaceImpl(userToken);
                RunspaceCacheValue value2     = new RunspaceCacheValue
                {
                    CostHandle = costHandle,
                    UserToken  = (PswsAuthZUserToken)userToken
                };
                ExTraceGlobals.PublicPluginAPITracer.TraceDebug <string, TimeSpan>((long)this.GetHashCode(), "[PswsBudgetManager.StartRunspace] Add value {0} to runspace cache. Expired time = {1}.", runspaceCacheKey, this.pswsRunspaceCacheTimeout);
                this.runspaceCache.InsertAbsolute(runspaceCacheKey, value2, this.pswsRunspaceCacheTimeout, new RemoveItemDelegate <string, RunspaceCacheValue>(this.OnRunspaceCacheItemExpired));
            }
            ExTraceGlobals.PublicPluginAPITracer.TraceDebug <string>((long)this.GetHashCode(), "[PswsBudgetManager.StartRunspace] Add/Update value {0} to connectedUser cache.", runspaceCacheKey);
            this.connectedUsers.AddOrUpdate(runspaceCacheKey, ExDateTime.Now, (string key, ExDateTime value) => ExDateTime.Now);
            AuthZPluginHelper.UpdateAuthZPluginPerfCounters(this);
        }
 // Token: 0x060012B6 RID: 4790 RVA: 0x0003C9FC File Offset: 0x0003ABFC
 private void OnRunspaceCacheItemExpired(string key, RunspaceCacheValue value, RemoveReason reason)
 {
     ExTraceGlobals.PublicPluginAPITracer.TraceDebug <string, RemoveReason>((long)this.GetHashCode(), "[PswsBudgetManager.OnRunspaceCacheItemExpired] item {0} is removed. Reason = {1}", key, reason);
     if (reason != RemoveReason.Removed)
     {
         try
         {
             if (value != null)
             {
                 if (value.CostHandle != null)
                 {
                     value.CostHandle.Dispose();
                 }
                 else
                 {
                     ExTraceGlobals.PublicPluginAPITracer.TraceDebug((long)this.GetHashCode(), "[PswsBudgetManager.OnRunspaceCacheItemExpired] value.CostHandle = null");
                 }
                 if (value.UserToken == null)
                 {
                     ExTraceGlobals.PublicPluginAPITracer.TraceDebug((long)this.GetHashCode(), "[PswsBudgetManager.OnRunspaceCacheItemExpired] value.UserToken = null");
                 }
                 else
                 {
                     base.RemoveBudgetIfNoActiveRunspace(value.UserToken);
                     string     runspaceCacheKey = this.GetRunspaceCacheKey(value.UserToken);
                     ExDateTime exDateTime;
                     if (runspaceCacheKey != null && this.connectedUsers.TryRemove(runspaceCacheKey, out exDateTime))
                     {
                         ExTraceGlobals.PublicPluginAPITracer.TraceDebug <string>((long)this.GetHashCode(), "[PswsBudgetManager.OnRunspaceCacheItemExpired] User {0} is removed from connectedUsers cache.", runspaceCacheKey);
                     }
                 }
             }
         }
         finally
         {
             AuthZPluginHelper.UpdateAuthZPluginPerfCounters(this);
         }
     }
 }