public static void ForwardAllResultsToCmdlet(ThrottlingJob throttlingJob, Cmdlet cmdlet, CancellationToken?cancellationToken)
            {
                using (var helper = new ForwardingHelper(throttlingJob))
                {
                    try
                    {
                        throttlingJob.ChildJobAdded += helper.ThrottlingJob_ChildJobAdded;

                        try
                        {
                            throttlingJob.StateChanged += helper.ThrottlingJob_StateChanged;

                            IDisposable cancellationTokenRegistration = null;
                            if (cancellationToken.HasValue)
                            {
                                cancellationTokenRegistration = cancellationToken.Value.Register(helper.CancelForwarding);
                            }

                            try
                            {
                                Interlocked.MemoryBarrier();
                                ThreadPool.QueueUserWorkItem(
                                    delegate
                                {
                                    helper.StartMonitoringJob(throttlingJob);
                                    foreach (Job childJob in throttlingJob.GetChildJobsSnapshot())
                                    {
                                        helper.StartMonitoringJob(childJob);
                                    }

                                    helper.CheckIfThrottlingJobIsComplete();
                                });

                                helper.ForwardResults(cmdlet);
                            }
                            finally
                            {
                                if (cancellationTokenRegistration != null)
                                {
                                    cancellationTokenRegistration.Dispose();
                                }
                            }
                        }
                        finally
                        {
                            throttlingJob.StateChanged -= helper.ThrottlingJob_StateChanged;
                        }
                    }
                    finally
                    {
                        throttlingJob.ChildJobAdded -= helper.ThrottlingJob_ChildJobAdded;
                    }
                }
            }
Example #2
0
 public void AddForwardAddress(string address)
 {
     Forwarding();
     ForwardingHelper.DeletAddreses(_driver);
     _forwardingPageModel.AddForwardingAddress.Click();
     _forwardingPageModel.ForwardingAddressInput.SendKeys(address);
     _forwardingPageModel.ForwardingNextButton.Click();
     _driver.SwitchTo().Window(_driver.WindowHandles.ToList().Last());
     _forwardingPageModel.ProceedButton.Click();
     _driver.SwitchTo().Window(_driver.WindowHandles.ToList().First());
     _forwardingPageModel.ForwardingOkButton.Click();
     _driver.WaitForAjax();
 }
Example #3
0
 private void ForwardAllResultsToCmdlet(Cmdlet cmdlet, CancellationToken?cancellationToken)
 {
     base.AssertNotDisposed();
     ForwardingHelper.ForwardAllResultsToCmdlet(this, cmdlet, cancellationToken);
 }
Example #4
0
            public static void ForwardAllResultsToCmdlet(ThrottlingJob throttlingJob, Cmdlet cmdlet, CancellationToken? cancellationToken)
            {
                using (var helper = new ForwardingHelper(throttlingJob))
                {
                    try
                    {
                        throttlingJob.ChildJobAdded += helper.ThrottlingJob_ChildJobAdded;

                        try
                        {
                            throttlingJob.StateChanged += helper.ThrottlingJob_StateChanged;

                            IDisposable cancellationTokenRegistration = null;
                            if (cancellationToken.HasValue)
                            {
                                cancellationTokenRegistration = cancellationToken.Value.Register(helper.CancelForwarding);
                            }
                            try
                            {
                                Interlocked.MemoryBarrier();
                                ThreadPool.QueueUserWorkItem(
                                        delegate
                                        {
                                            helper.StartMonitoringJob(throttlingJob);
                                            foreach (Job childJob in throttlingJob.GetChildJobsSnapshot())
                                            {
                                                helper.StartMonitoringJob(childJob);
                                            }

                                            helper.CheckIfThrottlingJobIsComplete();
                                        });

                                helper.ForwardResults(cmdlet);
                            }
                            finally
                            {
                                if (cancellationTokenRegistration != null)
                                {
                                    cancellationTokenRegistration.Dispose();
                                }
                            }
                        }
                        finally
                        {
                            throttlingJob.StateChanged -= helper.ThrottlingJob_StateChanged;
                        }
                    }
                    finally
                    {
                        throttlingJob.ChildJobAdded -= helper.ThrottlingJob_ChildJobAdded;
                    }
                }
            }