Most gui interfaces are not threadsafe, so you need to launch the thread BEFORE any gui code is used, and don't try to access gui widgets from the thread code block. Launching the thread before any gui code is written usally requires some shared variables to tell the thread code to start and stop. For a simple example of a sleeping thread, see PerlTk on a thread.... Of course, the while loop in the thread can become more complex, having nested loops for a working state, and a sleeping state. While in the sleeping state, it should regularily check for a shared variable telling it to run, and if you want to reuse the thread, it should check while it's running to drop back into the sleep state. Search groups.google.com for "perl tk sleeping thread" for more examples. Sorry I don't do much Wx.
Make your design to reuse threads, unless it's a 1-shot deal, because the thread ref-count cleanup is not perfect, and you will gain memory everytime you spawn a thread. Always try to reuse widgets and threads, and you will be happier in the long run.
In reply to Re^2: Wx subs and threads
by zentara
in thread Wx subs and threads
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |