Please explain Wx::Thread example

113 Views Asked by At

The documentation for Wx::Thread includes a small but instructive example of how to post an event from a child thread to a window in the main or parent thread.

What I cannot understand is how it can possibly be valid to refer to the file-scoped lexical variable $frame from the child thread as illustrated. The sequence of events is as follows: 1) start child thread; 2) initialize $frame; 3) ...time passes...; 4) child thread posts event to $frame.

I had thought that all non-shared variables get cloned when a thread starts. How can $frame be anything but undef in the child thread?

enter image description here

0

There are 0 best solutions below