Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Support Jobs - Redundant Methods #7322

Closed
4 tasks
juvtib opened this issue Mar 7, 2021 · 1 comment
Closed
4 tasks

How to Support Jobs - Redundant Methods #7322

juvtib opened this issue Mar 7, 2021 · 1 comment
Labels
area-sdk-docs Area - SDK docs resolution-wont-fix Status - closed as won't fix

Comments

@juvtib
Copy link
Contributor

juvtib commented Mar 7, 2021

  • 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);
        }
      }
    }

It doesn't seem like #5441 is resolved.

  • Step 5 might need to be updated.
  1. 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.

Return the appropriate objects, depending on whether the cmdlet is run as a background job.

  • The SDK might be affected.

// To load this cmdlet, create a module folder and copy the GetProcessSample06.dll
// assembly into the module folder.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@chasewilson chasewilson added the area-sdk-docs Area - SDK docs label Mar 8, 2021
@sdwheeler
Copy link
Contributor

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.

@sdwheeler sdwheeler added the resolution-wont-fix Status - closed as won't fix label Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-sdk-docs Area - SDK docs resolution-wont-fix Status - closed as won't fix
Projects
None yet
Development

No branches or pull requests

3 participants