Using Job Tracker

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.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
jsira2003@yahoo.com
Posts: 117
Last visit: Tue Jul 11, 2023 6:18 am

Re: Using Job Tracker

Post by jsira2003@yahoo.com »

Well I got the answer and the results that I wanted thanks to you. They key as it turned out was to get the results and process the array in the main task. I am not exactly sure why that made such a huge difference? I get to keep my wait state processing loop, my performance and no more not responding message. It's working like a champ!

Thank you very much!
John Sirabella
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Using Job Tracker

Post by jvierra »

This addresses part of what I was trying to tell you. Your code is a bit cumbersome and is memory wasteful. When you save arrays in a task and output the array you are actually doubling the memory requirements. Use the pipeline and this will not happen. Interim results will not be saved and the task will run much faster. A task runs best if you run a pipeline with no local collections and directly output the results of the pipeline. Sorts and groups will also cause excess overhead. They both cause all of the results to be saved in memory again. Format CmdLets will also cause all results to be saved, yet again, in memory.

For small scripts that collect little data this is not usually a problem. Once you exceed the physical memory allocation swapping will kill performance.

The other thing that will kill performance is running on a single processor system, running on a 32 bit system, running with less than optimal memory.

I haven't deployed less than a dual-core 64 bit system with 8Gb in at least 10 years. The difference in cost is minimal compared to the performance gains.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Using Job Tracker

Post by jvierra »

BY the way. This is the correct way to check job completion without a wait. It avoids constantly allocating new objects in a loop.

while (-not $myJob.IsCompleted){

Using a time to check the job also provides best performance and eliminates the expensive "DoEvents" and the loop.

JobTracker factors all of these issues in and is much easier to use. Just create three simple script blocks and run.
This topic is 5 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked