Board index » cppbuilder » Passing Arguments to a thread?

Passing Arguments to a thread?

In BCB4, when I create a thread object, is there any way to specify that the
Execute method should take arguments?  I tried looking for the mythread.h
file to customize the Execute, but I can't find it.

Andre

 

Re:Passing Arguments to a thread?


Instead of passing parameters to the thread Execute method, try creating 1
or more public functions in the thread class.  Call these methods in the
context of the thread that contains the reference to the background thread.
After this initialization period, run the thread to finally call the Execute
method.  I've done this with several thread classes since I had to pass
quite a few parameters to background threads before they executed.  And, if
you need to pass parameters while it's running, simply wrap a critical
section around the data access where needed.

Paul

Quote
"Andre Costopoulos" <costopoul...@easternct.edu> wrote in message

news:3b4dbd6d_2@dnews...
Quote
> In BCB4, when I create a thread object, is there any way to specify that
the
> Execute method should take arguments?  I tried looking for the mythread.h
> file to customize the Execute, but I can't find it.

> Andre

Re:Passing Arguments to a thread?


Another alternative is to add the parameters to the thread's constructor
itself, that way yu can pass them in when you first create the thread before
it runs.

Gambit

Quote
Paul Machiaverna <machi...@i-stat.com> wrote in message

news:3b4dc2a3$2_2@dnews...
Quote
> Instead of passing parameters to the thread Execute method, try creating 1
> or more public functions in the thread class.

Re:Passing Arguments to a thread?


I think this is what I was looking for.  Thanks

Andre

Other Threads