Gen EDGE

  • 1.  How to add a timer for GUI application to wait for external thread?

    Posted Jun 28, 2016 09:35 AM

    Hi,

     

    I would like to run a batch file from coolgen GUI window client using invoke launch function. The batch file communicate with FTP server and return a text file to my local machine. Then i want to check if the file exist on my machine. If doesn't exist, i need to put a exit state for the user. Fileexists function is there to do that which is not my problem.

     

    However, Coolgen triggers the batch command script and the script is running as a separate thread on my local machine. Coolgen doesn't wait or hold for the thread to be completed; very soon the next statement is executed before even the script complete running. So we need to have a hold on the independently running thread and wait for its completion.

     

    I want to know if there is any way to achieve this requirement in coolgen. Kindly suggest. Thanks

     

    Vijayakumar



  • 2.  Re: How to add a timer for GUI application to wait for external thread?

    Broadcom Employee
    Posted Jun 28, 2016 11:37 AM

    Vijaykumar,

     

    Is the batch file required to complete what you need?  If not, you can code all of the functionality that exists in the batch directly in a external action block.  With an EAB, it will execute to completion before returning to the Gen application.

     

    Regards,

    Andy Hebert

    CA Gen Support



  • 3.  Re: How to add a timer for GUI application to wait for external thread?

    Posted Jun 29, 2016 01:49 AM

    Yeah. I wanna complete batch command script (.bat) before executing next coolgen statement.



  • 4.  Re: How to add a timer for GUI application to wait for external thread?

    Broadcom Employee
    Posted Jun 29, 2016 02:55 PM

    Vijaykumar,

     

      I recommend you code an External Action Block to do the same functions as the BAT file.  Gen will wait for the EAB to complete before resuming.  Another alternative is to use inline code to code the same functionality done by the BAT file.

      If the BAT file is required, I will leave this to others to comment on how to wait for BAT file execution to complete.

     

    Regards,

    Andy Hebert

    CA Support



  • 5.  Re: How to add a timer for GUI application to wait for external thread?

    Posted Jun 30, 2016 01:44 AM

    Whilst it is known that no dedicative function is available to control batch thread, I found a way to fool around the program by looping for few seconds and then look for the output file which must have been created by the batch program. This method is beneficial only when the batch process complete in determined T seconds. Any delay would cause the coolgen program unable to find the output file. Ofcourse I need to handle it.

     

     

    Thanks a lot Andy for your valuable suggestion.

     

     

    Vijayakumar



  • 6.  Re: How to add a timer for GUI application to wait for external thread?

    Posted Jun 30, 2016 03:44 AM

    You can achieve what you want with an EAB.

     

    Use C code:

     

    CreateProcess() to run the batch file

     

    followed by:

     

    WaitForSingleObject() to wait for the process to finish

     

    and

     

    GetExitCodeProcess() to check the return code from the batch file.

     

    You mention running the batch file in a separate thread., but this should not be necessary if you are waiting for it. You would only want to create a separate thread if you also want to process some other code whilst the batch file is running.



  • 7.  Re: How to add a timer for GUI application to wait for external thread?

    Posted Jul 01, 2016 06:48 AM

    Thank You Andy and Darius.



  • 8.  Re: How to add a timer for GUI application to wait for external thread?

    Posted Jul 05, 2016 12:54 PM

    Note that starting with Gen 8.5, you can add language-specific code directly in the Action Diagram w/o having to use an EAB by using the Inline Code statement.