Simple Threading Question

G

gnassar

I'm attempting to use threads in .NET VC++ comming from a strict C
background. Unfortunately I'm a bit rough. I've gotten a rather good
knowlege of VC++ and have been converting projects from VB and C# to
learn how to do them in VC++ .NET.

Unfortunately I can't seem to understand something rather trivial. I
guess it escapes me.

I have a class, Form1. It creates 5 threads. Each thread I'd like to
know the parent address in. So I'd like each thread to know and be able
to access the Inital thread (The one Form1 loads from). Inside Form1 I
have a function String^ Form1::getString(); It returns a string of
course. I'd like the threads to call that. I have a mutex placed inside
to force multithreaded safety.

How would I go about defining the parent in the threads. Note the
threads are an instantiation of a totally different class than Form1.

Thanks in advance
 
G

Guest

I have a class, Form1. It creates 5 threads. Each thread I'd like to
know the parent address in. So I'd like each thread to know and be able
to access the Inital thread (The one Form1 loads from). Inside Form1 I
have a function String^ Form1::getString(); It returns a string of
course. I'd like the threads to call that. I have a mutex placed inside
to force multithreaded safety.

How would I go about defining the parent in the threads. Note the
threads are an instantiation of a totally different class than Form1.

Hi,

You can use a ParameterizedThreadStart delegate for that, and simply supply
the Form pointer when you start the thread.
See
http://msdn2.microsoft.com/en-us/library/system.threading.parameterizedthreadstart.aspx
for more information and an example.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top