public override void Activate()
 {
     ElapsedTimeWatcher.Watch(RequestStatistics.RequestStatItem.ActivateReportingWebServiceHostLatency, delegate
     {
         ReportingWebServiceHost.activeRunspaceCounters.Increment();
         this.averageActiveRunspace.Start();
         this.< > n__FabricatedMethod1();
     });
Beispiel #2
0
        public override InitialSessionState GetInitialSessionState()
        {
            InitialSessionState state = null;

            ElapsedTimeWatcher.Watch(RequestStatistics.RequestStatItem.GetInitialSessionStateLatency, delegate
            {
                state = this.< > n__FabricatedMethod3();
            });
            public override PSHost CreatePSHost()
            {
                ReportingWebServiceHost host = null;

                ElapsedTimeWatcher.Watch(RequestStatistics.RequestStatItem.CreatePSHostLatency, delegate
                {
                    host = new ReportingWebServiceHost();
                });
                return(host);
            }
Beispiel #4
0
        protected override Runspace CreateRunspace(PSHost host)
        {
            Runspace runspace2;

            using (new AverageTimePerfCounter(RwsPerfCounters.AveragePowerShellRunspaceCreation, RwsPerfCounters.AveragePowerShellRunspaceCreationBase, true))
            {
                Runspace runspace = null;
                ElapsedTimeWatcher.Watch(RequestStatistics.RequestStatItem.PowerShellCreateRunspaceLatency, delegate
                {
                    runspace = this.< > n__FabricatedMethod5(host);
                });
        public static PowerShellResults Invoke(this PSCommand psCommand, RunspaceMediator runspaceMediator)
        {
            PowerShellResults results = null;

            ElapsedTimeWatcher.Watch(RequestStatistics.RequestStatItem.InvokeCmdletLatency, delegate
            {
                using (RunspaceProxy runspace = new RunspaceProxy(runspaceMediator))
                {
                    try
                    {
                        ElapsedTimeWatcher.Watch(RequestStatistics.RequestStatItem.InvokeCmdletExcludeRunspaceCreationLatency, delegate
                        {
                            using (PowerShell powerShell = runspace.CreatePowerShell(psCommand))
                            {
                                try
                                {
                                    Collection <PSObject> output = null;
                                    ElapsedTimeWatcher.Watch(RequestStatistics.RequestStatItem.InvokeCmdletExclusiveLatency, delegate
                                    {
                                        output = powerShell.Invoke();
                                    });
                                    ErrorRecord[] array = new ErrorRecord[powerShell.Streams.Error.Count];
                                    powerShell.Streams.Error.CopyTo(array, 0);
                                    results = new PowerShellResults(output, new Collection <ErrorRecord>(array));
                                }
                                catch (RuntimeException ex)
                                {
                                    ErrorRecord errorRecord3;
                                    if (ex.ErrorRecord != null && !(ex is ParameterBindingException))
                                    {
                                        errorRecord3 = ex.ErrorRecord;
                                    }
                                    else
                                    {
                                        errorRecord3 = new ErrorRecord(ex, string.Empty, ErrorCategory.NotSpecified, null);
                                    }
                                    results = new PowerShellResults(new Collection <ErrorRecord>(new ErrorRecord[]
                                    {
                                        errorRecord3
                                    }));
                                }
                            }
                        });
                    }
                    catch (OverBudgetException exception)
                    {
                        ErrorRecord errorRecord = new ErrorRecord(exception, string.Empty, ErrorCategory.NotSpecified, null);
                        results = new PowerShellResults(new Collection <ErrorRecord>(new ErrorRecord[]
                        {
                            errorRecord
                        }));
                    }
                    catch (ADTransientException exception2)
                    {
                        ErrorRecord errorRecord2 = new ErrorRecord(exception2, string.Empty, ErrorCategory.NotSpecified, null);
                        results = new PowerShellResults(new Collection <ErrorRecord>(new ErrorRecord[]
                        {
                            errorRecord2
                        }));
                    }
                }
            });
            return(results);
        }