Deadlock in GetWindowTextLength, wxDialog with a Thread

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
volkan
In need of some credit
In need of some credit
Posts: 1
Joined: Wed Nov 15, 2006 8:31 am

Deadlock in GetWindowTextLength, wxDialog with a Thread

Post by volkan » Wed Nov 15, 2006 8:42 am

Hi,

I have a wxDialog and a Thread (which is not a wxThread). The Thread is updating wxTextCtrl's in my dialog. I get a deadlock, when I close the dialog. I catch the wxCloseEvent when closing, I stop the thread and call Destroy(). But when i close the dialog , during the thread is updating, I get a deadlock.

The Thread is calling the MFC method GetWindowTextLength an this is not coming back. I close the dialog by pressing the (X) on the right top.

Is there a earlier time to catch a EVT_CLOSE()?

I'm looking to read from you.

Thx, Volkan

Peer Sommerlund
Knows some wx things
Knows some wx things
Posts: 43
Joined: Tue Jun 13, 2006 7:21 am
Location: Denmark
Contact:

Post by Peer Sommerlund » Mon Nov 20, 2006 8:46 am

Uh, maybe the problem is that when you destroy a thread under Windows, it will die immedieately? That could explain why the thread does not return.

If this is the case, then you can solve it by using a mutex/critical section to prevent the destruction of the thread while it is updating:
- enter section when thread is working, exit when done.
- Enter section when destroying thread, exit when done.


(It should be possible to do this with wxThread as well)

Post Reply