Start-Job - Real time Updates

Support for all customers who have purchased a SAPIEN PowerShell Studio product license. This forum does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE 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.
User avatar
njcappa
Posts: 63
Joined: Wed May 04, 2016 6:50 am

Start-Job - Real time Updates

Post by njcappa » Thu Sep 13, 2018 3:58 pm

*** 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: 5400
Joined: Thu Aug 18, 2011 4:56 am

Re: Start-Job - Real time Updates

Post by davidc » Fri Sep 14, 2018 7:16 am

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: 63
Joined: Wed May 04, 2016 6:50 am

Re: Start-Job - Real time Updates

Post by njcappa » Fri Sep 14, 2018 7:52 am

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: 63
Joined: Wed May 04, 2016 6:50 am

Re: Start-Job - Real time Updates

Post by njcappa » Sat Sep 15, 2018 9:36 am

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: 5400
Joined: Thu Aug 18, 2011 4:56 am

Re: Start-Job - Real time Updates

Post by davidc » Mon Sep 17, 2018 7:23 am

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: 63
Joined: Wed May 04, 2016 6:50 am

Re: Start-Job - Real time Updates

Post by njcappa » Mon Sep 17, 2018 7:59 am

I'll do that, thanks again, David.