Jump to content
alogrep

Can a Critical section created and used in the app interfere with the Vcl.Dialogs critical section mechanisms?

Recommended Posts

I received a message from vcl.dialogs that sai=ys something about a criticalsection conflict (unfortunately I did not write  down the message, and is hard to reproduce. It happend twice, then in a dozen trials doing the identical steps it did not show up).
I have a Tcriticalsection instance defined in one of my units and it is used in a thread, but it is always used in a acquaire/release pair in a try/finally block.
This happened in the IDE, where I have some breakpoints and I stopped the execution for several seconds.

Share this post


Link to post

In my experience when timing can cause errors it always can be tracked back to incorrect thread data / UI access.

- Instead of just one critical section have one for each of your properties and enter / leave in every getter and setter.

- Make sure none of your thread accesses any UI elements directly (e.g. Form1.Memo1.Text)

- Make sure that every callback what your thread has is properly synchronized

- A dialog IS a part of the VCL thread. Do not show any dialog boxes in any threads!

Share this post


Link to post

Did the message came from the IDE or your application? Without having the message text and your code it is hard to diagnose what is wrong. Also, there are no critical sections in Vcl.Dialogs. 

Share this post


Link to post
9 hours ago, Dalija Prasnikar said:

Also, there are no critical sections in Vcl.Dialogs. 

And even if there was, critical sections are not named kernel objects, so they can't interfere with each other.

  • Like 2

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×