1. paulo gomes
  2. PowerBuilder
  3. Thursday, 3 May 2018 20:48 PM UTC

Hi All,

A .Net target DLL generated with PB 2017 R2 is called from a web service. It is fast  and works as expected with a single web service request. With concurrent requests to the web service (two Users or more) the behavior is as follows:

 1. both requests are hanging and never finished and time out                           or

 2. when the second request hits the DLL the first request aborts and the second finishes properly

The web service is multi-thread and my understand is that the DLL should be instantiated for each request. However it seems to be shared.

Questions:

     1. Is a PB .Net Target generated DLL thread safe, so it can be invoked in a multi-thread environment?

Any suggestions or ideas on how to overcome this situation are welcome.

Thank you,

Paulo Gomes

Interval Leisure Group

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 4 May 2018 13:28 PM UTC
  2. PowerBuilder
  3. # 1

Hi Paulo;

   AFAIK, PB Classic built .Net Assemblies were never designed to be fully thread safe. Since PB 2017 is built upon PB 12.6 Classic, I suspect that this restriction is the same as the architecture did not change. Making sure that your PowerScript code uses Pseudo-Conversational coding practices though should address most of the basic multithreading limitations.

  In the mean-time, I believe that you can make the current .Net assembly thread-safe by following this PB Guide information.

Note: The multithreading issue will be addressed much further in PB 018's new C# Web API and .Net Assembly features.

HTH

Regards ... Chris

Comment
  1. paulo gomes
  2. Friday, 4 May 2018 15:52 PM UTC
Hi Chris,



Thank you for the reply.



I read the PB Guide article you mentioned on Sysbooks and it seems to allow to make the DLL thread-safe by wrapping the function you want to call between statements like 





System.Threading.Monitor.Enter(obj) and





System.Threading.Monitor.Exit(obj);



if you are using PB .Net, not the Classic.



Since I'm using PB2017 R2 built on Classic PB 12.6, the .Net classes and objects are not available in my environment.



Any other ideas?



Thank you for your time.



Paulo Gomes



Interval Leisure Group

  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 4 May 2018 18:39 PM UTC
Hi Paulo;



  Just add that .NET feature to your .Net Assembly project in PB 2017 IDE, as follows:



Add .NET Assembly (RHMB on your PB Target) then select .Net assemblies







Select the "mscorlib.dll" .Net Assembly







 



Open the .Net Assembly in the PB IDE's System Tree ...







Scroll down to the Threading section and select the class and property / method you want to use...







 



HTH

  1. Helpful
  1. paulo gomes
  2. Saturday, 5 May 2018 23:29 PM UTC
Hi Chris,



Thank you for the reply.



The PB .Net DLL is added as reference in a VS C# web service that I coded and deployed to IIS. The web service accepts requests from a web site and redirect the calls to the corresponding method in the PB DLL. 



Everything works fine and very fast for 1 request. Apparently when a second request hits IIS, both processes hang and never end, no error returned.



I'll try to add the mscorlib.dll to the target and figure out which methods to use.  The idea is to "tell" that the PB DLL is thread safe or not to be shared inside a IIS single work process.



Thank you for your help.



Cheers,



Paulo Gomes



Interval Leisure Group

  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.