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(); } }
private void CheckIfRunspaceIsAvailable(object sender, RunspaceAvailabilityEventArgs runspaceAvailabilityEventArgs) { if (runspaceAvailabilityEventArgs.RunspaceAvailability == RunspaceAvailability.Available) { _availableEvent.Set(); } else { _availableEvent.Reset(); } }
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; }
protected override void OnAvailabilityChanged(RunspaceAvailabilityEventArgs e) { EventHandler <RunspaceAvailabilityEventArgs> availabilityChanged = this.AvailabilityChanged; if (availabilityChanged != null) { try { availabilityChanged(this, e); } catch (Exception exception) { CommandProcessorBase.CheckForSevereException(exception); } } }
static void runspace_AvailabilityChanged(object sender, RunspaceAvailabilityEventArgs e) { // Console.WriteLine("RunspaceAvailability = " + e.RunspaceAvailability.ToString()); }
void Runspace_AvailabilityChanged(object sender, RunspaceAvailabilityEventArgs e) { Tracer.TraceInformation("runspace-availability {0}", e.RunspaceAvailability); }
private void Runspace_AvailabilityChanged(object sender, RunspaceAvailabilityEventArgs e) { //Debug.WriteLine("Runspace: " + e.RunspaceAvailability); }
/// <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()); }