Question

How to find and save a Thread details and then kill that thread on user action

Hi, I want to find and save current running thread details into variables and then on user action like on click of a button, I want to kill that previous thread. The main reason for this is.. one of the application that we are automating is very slow and it hangs few times and it runs in the background. If the user feels that it been hanging there for a while, there should be a way to kill that previous thread and start the process again. Can anyone Please let me know how to achieve this using Pega Robotics. Thanks,

Comments

Keep up to date on this post and subscribe to comments

Pega
August 6, 2018 - 5:29pm

This would require C# on your part as it is not available within the product. If you are simply looking to terminate a specific adapter, then you can do that by calling Stop on the adapter. You can also use the static method Process.GetProcessesByName to locate a specific process and Kill it.

August 7, 2018 - 9:48am
Response to tsasnett

Hi Sasnt,

 

Thanks for your reply.

I don't want to kill the whole process. To restart the our process it will take at least 5 mins to launch the application and login.

So, I just want to kill the running thread only.  Please provide me C# code or any reference to achieve it.

 

December 26, 2018 - 7:19pm
Response to ParamKonuganti

Hi ParamKonuganti,

I have a similar scenario to handle. If in case you were able to accomplish this, can you please guide me on how to achieve this.

 

Thanks,

Varun Podaralla

 

December 26, 2018 - 9:57pm
Response to VarunPodaralla

Hi Varun,

Sorry.. we couldn't achieve that. Please explain the scenario, we can try to see whether we can achieve the desired behavior in another way.

Thanks, 

 

 

December 27, 2018 - 2:27pm
Response to ParamKonuganti

Hi ParamKonuganti,

Thanks for the response. In my scenario I wanted to provide an option to the user to immediately halt the execution at that instance without even completing the execution of the current step. for e.g. when a user starts processing a card by clicking on start process, automation has to complete 12 steps and when user realizes at step 3 that this is not the correct card to be processed, then we should be able to provide a button to the user to halt the automation at that instance without even completing step 3. Please let me know if there is any way we can kill that thread and initiate a new one or anything similar to this approach.

Thanks,

Varun Podaralla

 

 

December 27, 2018 - 2:43pm
Response to VarunPodaralla

Hi Varun,

Please try and see whether the below helps 

In your case, Considering every step of the 12 Step process as separate automation, we can proceed or Stop that particular step using a Flag, which is set only when the user clicks Stop Button.

The execution flow of First Button Automation and Stop Button Automation should be Asynchronous. If it single Project, using GC boolean flag. If it multiple project solution, use the Global Dictionary boolean variable.

Thanks,

Pega
December 28, 2018 - 3:43pm
Response to VarunPodaralla

This functionality can be implemented using an activity. Once you start an activity, you have the ability to cancel an activity. The StartActivity method returns a value that you can then pass to the CancelActivity method of the Interaction Manager component. Cancelling an activity will stop the automation at the next execution path.