Job tracker - throtting jobs

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.
Post Reply
User avatar
robert.ganshorn
Posts: 39
Joined: Wed May 07, 2014 3:52 pm

Job tracker - throtting jobs

Post by robert.ganshorn » Tue Nov 21, 2017 4:55 pm

I am using the job tracker to launch multiple jobs, but only a few can run concurrently or I start getting call depth overflow errors.

Is it possible to queue jobs or launch jobs, but throttle them based upon a job count value? All while keeping the gui responsive of course. I can easily do it within the main form, but of course then the form freezes in the 'while' loop.

Rob

User avatar
jvierra
Posts: 11557
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Job tracker - throtting jobs

Post by jvierra » Tue Nov 21, 2017 5:06 pm

Yes but you will have to modify the job tracker extensively or, better yet, use a workflow.

User avatar
robert.ganshorn
Posts: 39
Joined: Wed May 07, 2014 3:52 pm

Re: Job tracker - throtting jobs

Post by robert.ganshorn » Fri Dec 01, 2017 12:58 pm

On a side note, I resolved this by creating temporary .job files for each job as they are launched. To keep started jobs from all running at the exact same time, there is a small random delay period in the startup of each job to stagger their start. The .job files are used to keep track of the jobs running and are removed as they complete. Each job count the .job files and loop when there are 4 or more. Maybe it's not the most elegant solution, but it works and isn't too convoluted. .job files are named after the job in question (ie: job1.job, job2.job etc).

Rob

User avatar
jvierra
Posts: 11557
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Job tracker - throtting jobs

Post by jvierra » Fri Dec 01, 2017 1:21 pm

You can just add a queuing mechanism to JobTracker and it will do the same thing and much more efficiently.

User avatar
robert.ganshorn
Posts: 39
Joined: Wed May 07, 2014 3:52 pm

Re: Job tracker - throtting jobs

Post by robert.ganshorn » Wed Dec 06, 2017 12:09 pm

Can you show an example?

Rob

User avatar
jvierra
Posts: 11557
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Job tracker - throtting jobs

Post by jvierra » Wed Dec 06, 2017 12:44 pm

I don't have an example.
Look into System.Collections.Generic.Queue

User avatar
JohnTitor
Posts: 23
Joined: Fri Nov 17, 2017 8:49 pm

Re: Job tracker - throtting jobs

Post by JohnTitor » Wed Dec 06, 2017 5:25 pm

I was hoping the same
I have a job that runs, 90% completes very quickly and displays and we have to wait another 10 seconds for the last job to finish

User avatar
jvierra
Posts: 11557
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Job tracker - throtting jobs

Post by jvierra » Wed Dec 06, 2017 5:45 pm

Also consider using a workflow as it can execute a number of items in parallel and execute new items as threads become available.

With a workflow you can set the concurrency and max pool size. The workflow then handles all queuing of tasks.

Post Reply