Forcing a form to close before process completes

Ask your PowerShell-related questions, including questions on cmdlet development!
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 11 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
StupidSexyFlanders
Posts: 107
Last visit: Thu Apr 29, 2021 8:47 am

Forcing a form to close before process completes

Post by StupidSexyFlanders »

I have built a form in PSS using the 'Process Tracker' control set. I have set the process to run, wait for 60 seconds, and then start over. The entire things works great. However, the 'stop process' button only seems to work while the process is actually running -- not during the 60 second wait timer.I have tinkered with adding an additional 'abort' button, putting the $buttonCancelProcess.Enabled variable in different places, and enabling the ControlBox. Nothing seems to work.Ideas?


mbaker2012-07-24 16:27:15
Mike
StupidSexyFlanders
Posts: 107
Last visit: Thu Apr 29, 2021 8:47 am

Forcing a form to close before process completes

Post by StupidSexyFlanders »

I have built a form in PSS using the 'Process Tracker' control set. I have set the process to run, wait for 60 seconds, and then start over. The entire things works great. However, the 'stop process' button only seems to work while the process is actually running -- not during the 60 second wait timer.I have tinkered with adding an additional 'abort' button, putting the $buttonCancelProcess.Enabled variable in different places, and enabling the ControlBox. Nothing seems to work.Ideas?


mbaker2012-07-24 16:27:15
Mike
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Forcing a form to close before process completes

Post by davidc »

Hard to tell what is happening without seeing the "stop process" button's click script block. If you are using the Process tracker control set, you can call the Stop-ProcessTracker function to stop all the running processing. If you want it to stop the processes when the form is closed you simply call the Stop-ProcessTracker function on the form's closed event: $formMain_FormClosed=[System.Windows.Forms.FormClosedEventHandler]{#Event Argument: $_ =
[System.Windows.Forms.FormClosedEventArgs] #Stop any pending
processes Stop-ProcessTracker} David
David
SAPIEN Technologies, Inc.
StupidSexyFlanders
Posts: 107
Last visit: Thu Apr 29, 2021 8:47 am

Forcing a form to close before process completes

Post by StupidSexyFlanders »

The progress bar isn't associated with the timer. The progress bar tracks the main process. Once that's done, the progress bar resets to a value of 0 and the timer starts. When it reaches 00, the main process starts again. This is all working fine.

What I need to be able to do is abort the script while the timer is still counting down. Seems that, while the timer is running, nothing else is clickable. I will try changing to the timer control. Maybe that will work better for me.
Mike
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Forcing a form to close before process completes

Post by jvierra »

Just add the control and doubleclick on it. The event will be on the scren and place your short code ther. When ready for it to run just $timer1.enabled=$true.

Set the properties for the time interval you need.
This topic is 11 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