Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This might be a long shot, but here is another possibility [the former answer may be more likely] (something I just ran across, but had known before): The use of Synchronize may be causing the deadlock. Here is a blog about why this happens: <a href="http://www.finalbuilder.com/Resources/Blogs/PostId/675/Delphi-Workaround-for-TThread-SynchronizeWaitFor-.aspx" rel="nofollow">Delphi-Workaround-for-TThread-SynchronizeWaitFor-.aspx</a></p> <p>The pertinent point from the article:</p> <blockquote> <p>Thread A calls Synchronize(MethodA)</p> <p>Thread B calls Synchronize(MethodB)</p> <p>Then, inside the context of the Main Thread: </p> <p>Main thread calls CheckSynchronize() while processing messages</p> <p>CheckSynchronize is implemented to batch-process all waiting calls(*). So it picks up the queue of waiting calls (containing MethodA and MethodB) and loops through them one by one. </p> <p>MethodA executes in the main thread's context. Assume MethodA calls ThreadB.WaitFor </p> <p>WaitFor calls CheckSynchronize to process any waiting calls to Synchronize </p> <p>In theory, this should then process ThreadB's Synchronize(MethodB), allowing Thread B to complete. However, MethodB is already a possession of the first CheckSynchronize call, so it never gets called.</p> <p>DEADLOCK!</p> </blockquote> <p><a href="http://qc.embarcadero.com/wc/qcmain.aspx?d=22267" rel="nofollow">Embarcadero QC article</a> describing the problem in more detail.</p> <p>While I don't see any ProcessMessages calls in the above code, or for that matter, a WaitFor that would be called during a Synchronize, it could still be a problem that at the point a synchronize is called, another thread calls the synchronize as well - but the main thread has already synchronized and is blocking. </p> <p>This didn't click with me at first, because I tend to avoid Synchronize calls like the plague and usually design UI updates from threads using other methods like message passing and thread safe lists with message notification instead of synchronize calls.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload