This sounds like that one DBC is opened in two datasessions. Could this be the cause?
For example when you switch out to the custom app method, do you open any tables at that time? The custom app method would probably be using the Default datasession. Open the table there, which would probably open the DBC as well, then close the table, but not the DBC. Now the DBC would be open in two datasessions.
If you don't open any tables in the custon app method, then it is probably not the problem. If it is, then send the custom app the datasessionid and force the custom app method to use the same datasession.
Good luck!