You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why does void DoProcessLogic(bool asJob) exist if ProcessRecord() uses job.ProcessJob()?
Alternatively, is it best practice to always create private SampleJob job = new SampleJob("Get-ProcAsJob") and use job.ProcessJob() even when asjob == false?
private SampleJob job = new SampleJob("Get-ProcAsJob");
protected override void ProcessRecord()
{
if (asjob)
{
JobRepository.Add(job);
WriteObject(job);
ThreadPool.QueueUserWorkItem(WorkItem);
}
else
{
job.ProcessJob();
foreach (PSObject p in job.Output)
{
WriteObject(p);
}
}
}
If the cmdlet performs the work, call the System.Management.Automation.Cmdlet.WriteObject method to return a process object to the pipeline. If the work is performed as a job, add child job to the job.
There are no plans to update these docs. If anyone can come up with a better working example and wants to submit code and an article, we would consider taking the submission.
void DoProcessLogic(bool asJob)
exist ifProcessRecord()
usesjob.ProcessJob()
?Alternatively, is it best practice to always create
private SampleJob job = new SampleJob("Get-ProcAsJob")
and usejob.ProcessJob()
even whenasjob == false
?It doesn't seem like #5441 is resolved.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: