When we started Cavo programming many years back, we quickly adopted opening often used database globally. Opening and closing them in a specific screen (class) or even a method was simply costing too much time and added a lot of code.
In X# we could (I understand) add asynchrone code. I can imagine that this could give problems; in a DBF the recordpointer could have been set to specific record to be updated by one procedure while an asynchrone method could change this record pointer in the global database so the wrong record can be updated in the mentioned first procedure.
We use ADS and often new code is done with SQL statements. But that doesn't change the question. I am not sure if it does on using another SQL based database.
How do others deal with that?
Dick
Opening databases global/local when using asynchrone methods
Opening databases global/local when using asynchrone methods
Hi Dick,
If an application keeps some workarea open for shared use, then I see two ways to solve this problem for asynchronous access:
1. Do not work directly with the shared workarea in the application code, but wrap it in some static class with the necessary set of methods. Within each method there must be a BEGIN LOCK ... END block when interacting with this workarea.
2. As far as I know, in X# a separate DataSession is allocated for each thread. As a result, each thread has its own independent set of workareas. Thus, each thread can independently open its shared workarea within the thread. In this case, synchronization when accessing the workarea is not needed.
Best regards,
Leonid
If an application keeps some workarea open for shared use, then I see two ways to solve this problem for asynchronous access:
1. Do not work directly with the shared workarea in the application code, but wrap it in some static class with the necessary set of methods. Within each method there must be a BEGIN LOCK ... END block when interacting with this workarea.
2. As far as I know, in X# a separate DataSession is allocated for each thread. As a result, each thread has its own independent set of workareas. Thus, each thread can independently open its shared workarea within the thread. In this case, synchronization when accessing the workarea is not needed.
Best regards,
Leonid
Best regards,
Leonid
Leonid