Ticket DQ7728
Visible to All Users

Fill (update) QuantumGrid from a thread..

created 19 years ago

I like to fill (update) a Grid width database data (MySQL) form a thread. Is this possible, if so can you tell me how?
Greetings
Hans

Comments (1)
Serge (DevExpress Support) 19 years ago

    As you probably know, our modern controls (including the ExpressQuantumGrid) are built on the technology which uses ViewInfo objects. They are calculated and cached using a rather complex mechanism. The ViewInfo for a particular Grid element is created only when necessary. For example, when the Grid data is updated, the ViewInfo of the corresponding data cells is recalculated (destroyed first and then created again). When one manages data via a separate thread, this leads to situations when ViewInfo instances are destroyed while another Grid routine still refers to it, leading to an AV during execution.
    Having examined the situation, we found that unfortunately it is impossible to completely catch all such situations. Our developers tried to lock ViewInfo objects, however, in some instances it was still possible to destroy them. We have spent some time researching available documentation on the development of multi-threaded applications and it looks like we have found a solution. Since the ViewInfo objects are created and managed from within the main thread, it is necessary to process all operations which may potentially affect these objects, in the main thread. This requires you to use the Synchronize method of a thread.
    NOTE: Please refer to the "Writing multi-threaded applications \ Coordinating threads \ Using the main VCL/CLX thread" and "TThread.Synchronize" topics in the Delphi documentation for more detailed information.
    Yes, we agree with you that synchronization of threads may reduce performance and critical sections are more effective. However, as we mentioned, our developers tried to use critical sections to protect ViewInfo objects but this did not completely resolve the problem.
    What is more, here are some quotes from the Delphi help which claims to use the main thread in such instances:
    (1)
    When you use objects from the VCL or CLX object hierarchies, their properties and methods are not guaranteed to be thread-safe. That is, accessing properties or executing methods may perform some actions that use memory which is not protected from the actions of other threads. Because of this, a main thread is set aside for access of VCL and CLX objects.
    (2)
    When using data access components, you must still wrap all calls that involve data-aware controls in the Synchronize method.
    Hopefully, this explanation was clear enough and will help you resolve the problems in your project.
    Thanks,
    Serge

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.