Latest B4a
I have an app with an activity and a service. The activity has a sub (in a class) that is called as a result of a button click, or a timer tick or something happening in the service (Bluetooth data received). Under the case I am working on at the moment the Activity is not paused - but under some circumstances could be.
I have been using CallSubDelayed3(...) in all three cases, the parameters specify the reason for the call so the sub can respond to the user, timeout something or display a message from the Bluetooth.
This generally works but there are occasions where the call from the service does not result in the sub running. I can tell this by logging each run of the sub and displaying the reason for the run (one of the parameters) and by logging the line before each callsubdelayed3 to see that it is executed and the request to run made.
The problem appears to be timing related and happens perhaps 25% of the time and seems to be related to my clicking the button just after the service has executed the callsubdelayed3 but before the sub has actually run as a result of that call. This is under the rapid debugger which does slow things down a bit and probably increases the time delay before the sub runs. The sub run requested by the service never happens but the button click run request does.
I assume i am correct to expect all callsubdelayed runs to result in execution of the target sub? (remembering the activity is not paused).
The target sub exists and runs as expected most of the time irrespective of the source of the callsubdelayed so it is not a call to a non-existent sub (which i do check for).
If it should work is there any way i can find out what is actually happening? (check the callsubdelayed stack perhaps?)
I have replaced the callsubdelayed3 calls with simple callsub3's and have not seen the problem since then. This has changed the timing so may not be a good fix. I think for other reasons that CallSubDelayed3 would be better so would really like to use that approach.
Steve
I have an app with an activity and a service. The activity has a sub (in a class) that is called as a result of a button click, or a timer tick or something happening in the service (Bluetooth data received). Under the case I am working on at the moment the Activity is not paused - but under some circumstances could be.
I have been using CallSubDelayed3(...) in all three cases, the parameters specify the reason for the call so the sub can respond to the user, timeout something or display a message from the Bluetooth.
This generally works but there are occasions where the call from the service does not result in the sub running. I can tell this by logging each run of the sub and displaying the reason for the run (one of the parameters) and by logging the line before each callsubdelayed3 to see that it is executed and the request to run made.
The problem appears to be timing related and happens perhaps 25% of the time and seems to be related to my clicking the button just after the service has executed the callsubdelayed3 but before the sub has actually run as a result of that call. This is under the rapid debugger which does slow things down a bit and probably increases the time delay before the sub runs. The sub run requested by the service never happens but the button click run request does.
I assume i am correct to expect all callsubdelayed runs to result in execution of the target sub? (remembering the activity is not paused).
The target sub exists and runs as expected most of the time irrespective of the source of the callsubdelayed so it is not a call to a non-existent sub (which i do check for).
If it should work is there any way i can find out what is actually happening? (check the callsubdelayed stack perhaps?)
I have replaced the callsubdelayed3 calls with simple callsub3's and have not seen the problem since then. This has changed the timing so may not be a good fix. I think for other reasons that CallSubDelayed3 would be better so would really like to use that approach.
Steve