Пример #1
0
        protected void EnforceDelay()
        {
            if (this.context.ErrorInfo.TerminatePipeline)
            {
                return;
            }
            IPowerShellBudget psbudget = this.PSBudget;

            if (psbudget != null)
            {
                T t = (default(T) == null) ? Activator.CreateInstance <T>() : default(T);
                DelayEnforcementResults delayEnforcementResults = t.EnforceDelay(this, ThrottlingModule <T> .costTypesInEnforceDelay, ThrottlingModule <T> .CmdletMaxPreferredDelay);
                LocalizedString         localizedString         = this.GenerateDelayInfoLogString(this.PSBudget, delayEnforcementResults);
                if (!string.IsNullOrEmpty(localizedString))
                {
                    string          text           = string.Format("; PolicyDN: {0}; Snapshot: {1}", psbudget.ThrottlingPolicy.GetIdentityString(), psbudget);
                    LocalizedString warningMessage = new LocalizedString(localizedString + text);
                    this.context.Items["ThrottlingInfo"] = text;
                    this.context.Items["DelayedInfo"]    = localizedString;
                    Guid uniqueId = this.context.UniqueId;
                    CmdletLogger.SafeSetLogger(uniqueId, RpsCmdletMetadata.ThrottlingInfo, text);
                    CmdletLogger.SafeSetLogger(uniqueId, RpsCmdletMetadata.DelayInfo, CmdletLogHelper.NeedConvertLogMessageToUS ? localizedString.ToString(CmdletLogHelper.DefaultLoggingCulture) : localizedString);
                    this.WriteCmdletMicroDelayMessage(warningMessage, delayEnforcementResults.DelayInfo.Delay.TotalSeconds);
                }
                PowerShellBudgetWrapper powerShellBudgetWrapper = psbudget as PowerShellBudgetWrapper;
                WorkloadManagementLogger.SetBudgetBalance(powerShellBudgetWrapper.GetInnerBudget().CasTokenBucket.GetBalance().ToString(), null);
            }
        }
Пример #2
0
        public void Dispose()
        {
            string budgetBalance;

            if (this.TryGetBudgetBalance(out budgetBalance))
            {
                WorkloadManagementLogger.SetBudgetBalance(budgetBalance, null);
            }
            this.CloseAllActions();
            this.AfterDispose();
        }