Using Powershell Studio 2015 64bit on Windows 2008 R2/2012
From a design perspective, you should never block the UI when running a long-running task. That's easy enough with C#/VB.NET but I'm wondering how to go about doing it with Powershell Studio?
I've a task that makes some changes on a remote registry, it takes about 20 seconds to complete. Currently, this blocks the UI and updates a textbox with progress of what's going on
Ideally, though, it should launch the function in a separate process and report its progress back to the calling thread so that the UI can be updated and left unblocked.
Has anyone got any guidelines on this ?
Any guides on asynchronous processing (i.e. not blocking UI)
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- SAPIEN Support Forums
- Posts: 945
- Last visit: Thu Oct 22, 2015 1:10 pm
Any guides on asynchronous processing (i.e. not blocking UI)
This is an automated post. A real person will respond soon.
Thank you for posting, ginolard.
Did you remember to include the following?
*** Make sure you do not post any licensing information ***
Thank you for posting, ginolard.
Did you remember to include the following?
- 1. Product, version and build (e.g. Product: PowerShell Studio 2014, Version & Build: 4.1.71. Version and build information can be found in the product's About box accessed by clicking the blue icon with the 'i' in the upper right hand corner of the ribbon.)
2. Specify if you are running a 32 or 64 bit version
3. Specify your operating system and if it is 32 or 64 bit.
4. Attach a screenshot if your issue can be seen on the screen
5. Attach a zip file if you have multiple files (crash reports, log entries, etc.) related to your issue.
*** Make sure you do not post any licensing information ***
Re: Any guides on asynchronous processing (i.e. not blocking
We have some articles covering this topic:
https://www.sapien.com/blog/2011/07/15/ ... ive-loops/
https://www.sapien.com/blog/2012/05/16/ ... ive-forms/
David
https://www.sapien.com/blog/2011/07/15/ ... ive-loops/
https://www.sapien.com/blog/2012/05/16/ ... ive-forms/
David
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Any guides on asynchronous processing (i.e. not blocking
That second one seems perfect. I need to have the UI be responsive whilst the application goes off and does some work on a remote machine (deleting reg keys, stopping/restarting a service).
I'm not clear, though, on how the UpdateScript block can be used to update a RichTextBox on the UI.
Ideally, in the Jobscript block it will return a "status message" after each operation. However, the Timer ticks every 100 milliseconds which means the Textbox just gets spammed with the last message returned (until the message changes).
How can I ensure that the timer only ticks after each operation is completed?
So, for example
I'm not clear, though, on how the UpdateScript block can be used to update a RichTextBox on the UI.
Ideally, in the Jobscript block it will return a "status message" after each operation. However, the Timer ticks every 100 milliseconds which means the Textbox just gets spammed with the last message returned (until the message changes).
How can I ensure that the timer only ticks after each operation is completed?
So, for example
- Display "Starting"
Delete regkey1
"Display delete regkey1"
Delete regkey2
"Display delete regkey2"
Delete regkey3
"Display delete regkey3"
Re: Any guides on asynchronous processing (i.e. not blocking
If you want to prevent the same output from duplicating, remove the -Keep switch from the Receive-Job cmdlet:
PowerShell Code
Double-click the code block to select all.$results = Receive-Job -Job $Job | Out-String $richtextbox1.AppendText($results)David
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.