private void ClearRunningJobList() { #if !CORECLR // Workflow Not Supported on OneCore PS UnsubscribeFromEngineWFJobStartEvent(); #endif PSJobStartEventArgs[] runningJobs = null; lock (_syncObject) { if (_runningJobs.Count > 0) { runningJobs = new PSJobStartEventArgs[_runningJobs.Values.Count]; _runningJobs.Values.CopyTo(runningJobs, 0); } } if (runningJobs != null) { foreach (var item in runningJobs) { RemoveFromRunningJobList(item.Job); } } }
private void AddToJobRunningList(PSJobStartEventArgs jobArgs, DebuggerResumeAction startAction) { bool newJob = false; lock (_syncObject) { jobArgs.Job.StateChanged += HandleJobStateChanged; if (jobArgs.Job.IsPersistentState(jobArgs.Job.JobStateInfo.State)) { jobArgs.Job.StateChanged -= HandleJobStateChanged; return; } if (!_runningJobs.ContainsKey(jobArgs.Job.InstanceId)) { // For now ignore WF jobs started asynchronously from script. if (jobArgs.IsAsync) { return; } // Turn on output processing monitoring on workflow job so that // the debug stop events can coordinate with end of output processing. jobArgs.Job.OutputProcessingStateChanged += HandleOutputProcessingStateChanged; jobArgs.Job.MonitorOutputProcessing = true; _runningJobs.Add(jobArgs.Job.InstanceId, jobArgs); jobArgs.Debugger.DebuggerStop += HandleMonitorRunningJobsDebuggerStop; jobArgs.Debugger.BreakpointUpdated += HandleBreakpointUpdated; newJob = true; } } if (newJob) { jobArgs.Debugger.SetParent( this, _idToBreakpoint.Values.ToArray<Breakpoint>(), startAction, _context.EngineHostInterface.ExternalHost, _context.SessionState.Path.CurrentLocation, GetFunctionToSourceMap()); } else { // If job already in collection then make sure start action is set. // Note that this covers the case where Debug-Job was performed on // an async job, which then becomes sync, the user continues execution // and then wants to break (step mode) into the debugger *again*. jobArgs.Debugger.SetDebuggerStepMode(true); } }