Progress bar and 'abort' button?

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 7 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
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Progress bar and 'abort' button?

Post by stevens »

Product, version and build: latest
32 or 64 bit version of product: 64
Operating system: 2012 r2
32 or 64 bit OS: 64
PowerShell Version: latest

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

Hi,

Simple question, don't know if the answer is too: is there a possibility to abort a running query/execution?
f.e. I have this button on my form which gets all computer information of a remote computer, it will show a message when not reachable but some machines are so slow that an abort should be possible in case it takes to long?

Please advise.
Steven
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Progress bar and 'abort' button?

Post by davidc »

[TOPIC MOVED TO THE POWERSHELL GUIS FORUM BY MODERATOR]

It really depends on what you are calling and how it is called, but I would recommend using a Job to run the query if you don't already. This way you try using the Stop-Job cmdlet to try to end the query.

For more information on how to use the Job Tracker Control Set in PowerShell Studio, please refer to the following article:

http://info.sapien.com/index.php/guis/g ... sive-forms
David
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Progress bar and 'abort' button?

Post by jvierra »

If you are using WMI then you might do better using CIm CmdLets as they have a timeout.

For most issues, as suggested by David, the Job Tracker is the easiest way to handle this.
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: Progress bar and 'abort' button?

Post by dan.potter »

see control sets in the left pane toolbox second button. It's a square with dots around it.

Here's a combination of the jobtracker and processtracker.
jtanimated.psf
(37.26 KiB) Downloaded 186 times
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Progress bar and 'abort' button?

Post by stevens »

Thanks, didn't use the job (yet), will try to implement that.
However, wanted to add a ' quicwkin' =

$MainForm.Cursor = 'WaitCursor' before and a $MainForm.Cursor = ''Default' after but it doesn't do anything.
Please advise on that.
This topic is 7 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