Click to See Complete Forum and Search --> : Passing reference to thread
gtsongi
March 16th, 2009, 03:19 PM
Hi!
I'm a newbie to C++. I'm using Visual C++ 2008.
I need to pass the reference of a PictureBox to a thread.
How can I do this?
I've created the thread like this:
Thread^ oThread =
gcnew Thread(gcnew ThreadStart( ThreadClass::ThreadFunction ) );
oThread->Start();
Thanks in advance!
Lindley
March 16th, 2009, 03:47 PM
That looks like managed code, better try the managed forum.
cilu
March 16th, 2009, 04:31 PM
[ redirected ]
See the overload of Start() that takes an object. There are examples in MSDN.
BTW, this is C++/CLI, not C++.
gtsongi
March 17th, 2009, 02:23 AM
Thanks for your reply!
I've tried overloading the Start() method, but the problem is that I can't convert the Object^ type to PictureBox^.
How can I convert Object^ to PictureBox^?
cilu
March 19th, 2009, 04:12 PM
What do you mean you tried overloading the Start() method?
Show us the code and we might be able to tell what the problem is.
To convert from object^ to PictureBox^ you use the dynamic_cast operator.
void func(Object^ ctrl)
{
PictureBox^ pb = dynamic_cast<PictureBox^>(ctrl);
}
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.