Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Opening databases global/local when using asynchrone methods 29 Aug 2022 12:58 #23504

  • ic2
  • ic2's Avatar
  • Topic Author


  • Posts: 1574
  • 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

    Please Log in or Create an account to join the conversation.

    Opening databases global/local when using asynchrone methods 29 Aug 2022 13:31 #23505

    • leon-ts
    • leon-ts's Avatar


  • Posts: 238
  • 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

    Please Log in or Create an account to join the conversation.

    Last edit: by leon-ts.
    • Page:
    • 1