Exemple #1
0
        private void HandleRunspaceAvailabilityChanged(object sender, RunspaceAvailabilityEventArgs e)
        {
            // Ignore nested commands.
            LocalRunspace localRunspace = sender as LocalRunspace;

            if (localRunspace != null)
            {
                var basePowerShell = localRunspace.GetCurrentBasePowerShell();
                if ((basePowerShell != null) && (basePowerShell.IsNested))
                {
                    return;
                }
            }

            RunspaceAvailability prevAvailability = _previousRunspaceAvailability;

            _previousRunspaceAvailability = e.RunspaceAvailability;

            if ((e.RunspaceAvailability == RunspaceAvailability.Available) || (e.RunspaceAvailability == RunspaceAvailability.None))
            {
                _debugBlockingCollection.Complete();
            }
            else if ((e.RunspaceAvailability == RunspaceAvailability.Busy) &&
                     ((prevAvailability == RunspaceAvailability.Available) || (prevAvailability == RunspaceAvailability.None)))
            {
                _newRunningScriptEvent.Set();
            }
        }
Exemple #2
0
 private void CheckIfRunspaceIsAvailable(object sender, RunspaceAvailabilityEventArgs runspaceAvailabilityEventArgs)
 {
     if (runspaceAvailabilityEventArgs.RunspaceAvailability == RunspaceAvailability.Available)
     {
         _availableEvent.Set();
     }
     else
     {
         _availableEvent.Reset();
     }
 }
Exemple #3
0
        private static void OnRunspaceAvailable(object sender, RunspaceAvailabilityEventArgs args)
        {
            if (args.RunspaceAvailability != RunspaceAvailability.Available)
            {
                return;
            }

            var runspace = (Runspace)sender;

            runspace.SessionStateProxy.InvokeCommand.InvokeScript("Write-Host 'Hello'");
            runspace.AvailabilityChanged -= OnRunspaceAvailable;
        }
Exemple #4
0
        protected override void OnAvailabilityChanged(RunspaceAvailabilityEventArgs e)
        {
            EventHandler <RunspaceAvailabilityEventArgs> availabilityChanged = this.AvailabilityChanged;

            if (availabilityChanged != null)
            {
                try
                {
                    availabilityChanged(this, e);
                }
                catch (Exception exception)
                {
                    CommandProcessorBase.CheckForSevereException(exception);
                }
            }
        }
Exemple #5
0
        static void runspace_AvailabilityChanged(object sender, RunspaceAvailabilityEventArgs e)
        {
//            Console.WriteLine("RunspaceAvailability = " + e.RunspaceAvailability.ToString());
        }
Exemple #6
0
 void Runspace_AvailabilityChanged(object sender, RunspaceAvailabilityEventArgs e)
 {
     Tracer.TraceInformation("runspace-availability {0}", e.RunspaceAvailability);
 }
Exemple #7
0
 private void Runspace_AvailabilityChanged(object sender, RunspaceAvailabilityEventArgs e)
 {
     //Debug.WriteLine("Runspace: " + e.RunspaceAvailability);
 }
Exemple #8
0
 /// <summary>
 /// Runspace availability change handler
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void _runspace_AvailabilityChanged(Object sender, RunspaceAvailabilityEventArgs e)
 {
     ServiceCommon.Log("Runspace Availability Changed: {0}", e.RunspaceAvailability.ToString());
 }