show jobs have completed

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 2 years and 8 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
Domtar
Posts: 133
Last visit: Mon Mar 11, 2024 5:38 am
Has voted: 2 times

show jobs have completed

Post by Domtar »

hi all,

I have a form that the Service Desk is using where I would run some stuff in the background with jobs. When a job is completed, I'd like to update a control saying that the job is ready to send data.

I have no idea how to write my function so that, whenever a job is ready, a control in the form would be updated to show that?

Should I use a timer and check jobs completion each X seconds? i don't really like that approach as it will get some CPU cliks for nothing if there are no jobs.

Can someone show me a better way to do this?

thanks!
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: show jobs have completed

Post by jvierra »

A tick event is about a billion times small as compared to any processor requirements. Don't try to optimize without understanding how computer systems and op-eratinfg systems work as it will just waste your time. To optimize we use tools like the system performance monitor and optimize where there is high usage. A tick would never show on a perfomance analysis.

Set your ticker to one second. That will cause a quick execution once per sencond.

It is even more efficient to not do a job just use code. Then the system will be less distracted and the process will suspend as needed and never get into the way of other processes.

It is necessary to have a good design reason to use jobs. If you are just running something periodically and whant a simple notification then just run a script and pop up a message box when the operation completes then loop again if needed.
User avatar
Domtar
Posts: 133
Last visit: Mon Mar 11, 2024 5:38 am
Has voted: 2 times

Re: show jobs have completed

Post by Domtar »

There are stuff in my GUI that take time to process and the GUI goes "not responding". To avoid that, I'd like to trigger these actions with a job instead.

so you say that i should add a timer to my GUI? I'll give that a try.

thanks!
This topic is 2 years and 8 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