1. Roland Smith
  2. PowerBuilder
  3. Friday, 19 January 2024 04:07 AM UTC

PB 2022 R3

I have a non-visual app that receives messages over Winsock and then processes the data and stores it in a database.

I first create an eight occurrence array of sharedobjects. I have an instance object (named Callback) that tracks whether the objects are busy with an instance boolean array.

To process each message I first check each of the eight to find the first one that isn't busy. I set it to busy, pass Callback to the background object (where it is saved to an instance variable), and then post the processing function. At the end of the processing function, I post a call to a function within Callback that is supposed to update the boolean marking the object as free.

Unfortunately, in the main thread, the boolean never gets updated so it runs into an all threads busy error.

I put logging in the callback function and it does write to the log. It seems like it is going to an alternate copy of the callback object.

My question then is how can the main thread receive notification from the background thread? This app has no windows, just non-visual objects.

I tried getting the handle of Callback so I could trigger an event using the Send function. The Handle function returns zero. I'm starting to wonder if I should use a hidden window.

René Ullrich Accepted Answer Pending Moderation
  1. Friday, 19 January 2024 06:39 AM UTC
  2. PowerBuilder
  3. # 1

Your approach sounds to be ok.

Maybe your callback object is autoinstantiated? It shouldn't.

Comment
  1. Chris Pollach @Appeon
  2. Friday, 19 January 2024 15:28 PM UTC
I agree Rene!

@Roland ... I do have a MT Demo App that I use built from the STD Framework. I will try & migrate that to PB 2022 R3 using the 2024R1 Beta framework I now have on SourceForge & see if that still runs OK.
  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.