Start-Job - Real time Updates

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
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.
This topic is 5 years and 6 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.
User avatar
njcappa
Posts: 66
Last visit: Tue Jan 26, 2021 6:59 am

Start-Job - Real time Updates

Post by njcappa »

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: Powershell Studio 2018
32 or 64 bit version of product: 64 Bit
Operating system: Win 10 Pro
32 or 64 bit OS: 64 Bit

Hi all - I'm using the start-job feature/button to call an exe that will perform a task, and then in the update script block, I've set the $results to a richtextbox. The problem I have is that the update script section isn't really showing the real-time update to the form, as it is based on a timer.
I also realize that we're not supposed to update any form control in the JobScript section.

I'm wondering if there is anyway around this at all, whereby the exe I call during the JobScript performs it's task and the result is sent to a textbox/richtextbox.

I need to run two separate external exe's concurrently, so that's why I'm looking to see if the above can be done somehow, without locking up the form.

thanks!
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Start-Job - Real time Updates

Post by davidc »

If you are calling an executable, you can redirect the output asynchronously. Please refer to this post:

viewtopic.php?f=21&t=12969&start=10

In the next service release, we will support output redirection in the Project Tracker control set.
David
SAPIEN Technologies, Inc.
User avatar
njcappa
Posts: 66
Last visit: Tue Jan 26, 2021 6:59 am

Re: Start-Job - Real time Updates

Post by njcappa »

Thanks David.

Having read through the post, I think it's ideal for what I intend to do. I'll implement and test as needed.

also, having it as a control set seems like an ideal addition - thanks.
User avatar
njcappa
Posts: 66
Last visit: Tue Jan 26, 2021 6:59 am

Re: Start-Job - Real time Updates

Post by njcappa »

David, I had a quick follow up question, to the link you posted regarding output redirect, above.

In the example code, the $process.StartInfo.Arguments = '' line points to the ping arguments one would use, but I have a CSV file that I need to import, and have this $process.StartInfo.Arguments reference data from a column of values in that CSV file.

my current code is to do this from a foreach-object on the csv import and call the exe, but that would lock up the form which is what I want to avoid.

Do you possibly have a suggestion for me so that I can "cycle" through the csv file and use this System.Diagnostics.Process object?

Hopefully my question made sense. Thanks again for the help.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Start-Job - Real time Updates

Post by davidc »

If you start a process by using System.Diagnostics.Process object, it will not lock up the form as long as you are not waiting for it to exit.

If you encounter issues, I recommend posting the code you have in our PowerShell GUIs forum:

viewforum.php?f=21
David
SAPIEN Technologies, Inc.
User avatar
njcappa
Posts: 66
Last visit: Tue Jan 26, 2021 6:59 am

Re: Start-Job - Real time Updates

Post by njcappa »

I'll do that, thanks again, David.
This topic is 5 years and 6 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.