Variable goes out of scope in the child thread when parent thread returns
ok guys,
a quick newbie question:
how do i pass a variable into a thread when i still need that variable AFTER the parent thread returns. after hours of experimenting, i found the problem is when the parent thread returns, the variable in the child thread (formally passed by the parent thread) goes out of scope and disappears....
A few ideas i thought of
1) use static ?? i am now too sure on this
2) use a gobal variable?? i think it still goes out of scope too
anyway this is not very elegant method
3) anything???
in summary:
- a user interface thread starts a worker thread
- user interface thread returns so that the program doesnt freeze
- worker thread still needs to work around with the variable
<-- problem with the retaining of the variable when user interface thread goes out of scope
using
- visual c++ 6.0
- win98SE
- API, dont know much about MFC till i learn more on the basic APIs that make up MFC