1. Miguel Alzate
  2. PowerBuilder
  3. Friday, 29 March 2019 11:50 AM UTC

Hi.

I'm new to C# programming. I need to asynchronously (from a Web service) run a number of instances of the same process and, then, check if they have all finished. For this, I use a C# process array. Could anyone please tell me if the following code is be correct (conditional compilation in bold)?

string ls_exe="c:\payroll.exe" //Process to be executed
string ls_parm //Command line argument of the process
integer li_n=5 //Number of instances of the process to be executed (actually an unknown and not fixed value)
integer li_proc //Number of executed instances of the process
integer li_done //Number of terminated instances of the process
integer li_k //For iteration

//Declare unbounded array of processes

#if defined pbwebservice then
     system.diagnostics.process proc[]
#end if

//Assign and execute the array of processes

do while true
     //For...Next not used because number of instances is actually unknown
     li_k ++
     ls_parm = string(li_k)
     #if defined pbwebservice then
          proc[li_k] = system.diagnostics.process.start(ls_exe, ls_parm)
     #end if
     if li_k > li_n then exit //No more instances to execute
loop

//Check for termination of all process instances in the array

#if defined pbwebservice then
     li_proc = proc.getupperbound(0) //Number of executed process instances
#end if

do while true //Scan continually the array to check termination
     for li_k = 0 to li_proc
          #if defined pbwebservice then
               if proc[li_k].hasexited then li_done ++ //Increase count of terminated instances
          #end if
     next
     if li_done = li_proc then exit //Number of terminated instances equals the number of executed instances
loop

//Display termination message

#if defined pbwebservice then
     console.writeline("All process instances have been terminated")
#end if

 

Accepted Answer
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Friday, 29 March 2019 23:34 PM UTC
  2. PowerBuilder
  3. # Permalink

I'm not a C# developer so I can't directly answer your question, but I can point out one key problem.  The conditional code block you wrote is not supported in the new C# Web API feature of PB 2019.  This conditional code block is a legacy PB.NET feature and not standard C# feature.  Everything PB does now for .NET is all standard C#.  

Comment
  1. Armeen Mazda @Appeon
  2. Saturday, 30 March 2019 00:26 AM UTC
All of them.. Conditional code blocks are not supported... you can't co-mingle PowerScript and C# in the C# Web API feature of PB 2019.

If you are not using the obsolete .NET Web service target in PB 2017 or older, then conditional code blocks are supported. However, I would advise against using the obsolete .NET Web service target for any new project because this is no longer being enhanced by Appeon. Also, it is legacy SOAP/XML interface rather than REST/JSON interface.

If you are existing PB 2017 customer you can try out the C# Web API in the beta version of PB 2019, and the final release is scheduled for May 31, 2019.
  1. Helpful
  1. Miguel Alzate
  2. Monday, 1 April 2019 14:56 PM UTC
Thanks a lot, Armeen. Question resolved!
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Monday, 1 April 2019 17:06 PM UTC
Great, and thanks for marking the question as answered!
  1. Helpful
There are no comments made yet.
Miguel Alzate Accepted Answer Pending Moderation
  1. Saturday, 30 March 2019 00:08 AM UTC
  2. PowerBuilder
  3. # 1

There are 5 conditional blocks in the code. Which of them is (are) not supported?

Thanks for replying!

Comment
  1. Miguel Alzate
  2. Saturday, 30 March 2019 00:14 AM UTC
BTW, How can I eliminate entries in this Q&A forum?
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Saturday, 30 March 2019 00:21 AM UTC
Armeen Mazda

I can't find a way to delete a reply, but you could click the "Edit" button and just clear your answer.

Comments can be deleted by clicking the "Remove" link at the end of your comment.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.