0
votes

Timer event when used causing PowerBuilder application crash. Application crashes at random time interval. Sometime it takes not more than a minute to crash and sometime there is no crashing even hitting with random mouse clicks, edit change and item change.

I cannot think of any test i can do to check the reason of crash. I dont know where to put TRY CATCH because code is very very simple. The doubtful thing is that the instance of the window i open with the timer set in its Open event makes application crash only when 2 instances are open at the same time.

The timer triggers a custom event and the custom event has one line of Retrieve function call for a DataWindow.

The doubtful thing with the retrievend Event of the Datawindow is Messagebox to display just a message saying 'data has been refreshed'.

1- The Open event sets timer for 10 seconds

2- Timer event calls dw_1.Retrieve()

3- RetrieveEnd event shows MessageBox

enter image description here

Is it in fact Timer event or something else causing the crash ?

1

1 Answers

0
votes

First off, the basics.

The one thing that triggers for me in your description is the messagebox. A MessageBox() is going to block processing of the message queue, while the Timer functionality will keep loading multiple Timer events to the queue. If I walk away from my computer for 10 minutes, I can’t imagine wanting this list to refresh 60 times in rapid succession with all the Timer events queued up. Additionally, depending on when PB yields to start processing more messages (I have a vague recollection that messages get processed during a Retrieve()), you might have multiple processing of the same event going on at the same time, and even worse, multiple simultaneous retrieves on the same DataWindow.

If it were me, I would either:

  1. Display my message in a non-modal way (e.g. a piece of statictext on the window).
  2. Prevent multiple simultaneous Timer events by turning off the Timer at the start of the Timer functionality and turning it back on at the end.
  3. Prevent multiple simultaneous Timer events with use of a flag, either instance or shared depending on how I want multiple instances of the window to be handled.

Good luck.