The code below creates a thread on a global function (ReadChildOutput):
CreateThread(NULL, 0, ReadChildOutput, (LPVOID)this, 0, &ThreadId);
How would I create a thread on a non-global function, assuming the
ReadChildOutput function were in the current class. This code illustrates
what I mean, but does not compile.
CreateThread(NULL, 0, this->ReadChildOutput, NULL, 0, &ThreadId);
Thanks,
Chris 2 1884
Chris LaJoie wrote: The code below creates a thread on a global function (ReadChildOutput):
CreateThread(NULL, 0, ReadChildOutput, (LPVOID)this, 0, &ThreadId);
How would I create a thread on a non-global function, assuming the ReadChildOutput function were in the current class. This code illustrates what I mean, but does not compile.
CreateThread(NULL, 0, this->ReadChildOutput, NULL, 0, &ThreadId);
Thanks, Chris
You have to use a "global" helper function. Pass the 'this' pointer as the
LPINFO parameter to CreateThread, and the address of the static function as
the start address. In the static function, cast the void* info into
CYourClass* and call the member function. From your example above, it looks
like you're already doing that.
-cd
Chris LaJoie wrote: The code below creates a thread on a global function (ReadChildOutput):
CreateThread(NULL, 0, ReadChildOutput, (LPVOID)this, 0, &ThreadId);
How would I create a thread on a non-global function, assuming the ReadChildOutput function were in the current class. This code illustrates what I mean, but does not compile.
CreateThread(NULL, 0, this->ReadChildOutput, NULL, 0, &ThreadId);
Chris
Briefly, the problem is that all class instance functions have an
implicit "this" as a first (hidden) argument. Thus it simply won't
compile or be the right shape!
/steveA
--
my email Fg**********@vqk.pbz is encrypted with ROT13 ( www.rot13.org) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Daylor |
last post by:
can i do it this way :
from the defualt AppDomain :
create thread.
from the start function of the new thread , create new AppDomain,and then
create my class through the AppDomain .
this way...
|
by: me |
last post by:
I have a Class Library that contains a Form and several helper classes. A
thread gets created that performs processing of data behind the scenes and
the Form never gets displayed (it is for debug...
|
by: me |
last post by:
I have a Class Library that contains a Form and several helper classes. A
thread gets created that performs processing of data behind the scenes and
the Form never gets displayed (it is for debug...
|
by: Bill Nguyen |
last post by:
How can I create a shared function to display process progress that can be
called from other routines within an application? Any example that I can
follow?
Thanks
Bill
|
by: Daylor |
last post by:
hi.
i have multi thread application in vb.net
is there a way NET support, so i can mark the class , to be access
only for 1 thread each time ?
if there is , small sytax sample will help
...
| |
by: Lonewolf |
last post by:
Hi all,
I'm having difficulties passing data back to managed class from my
native class when the data is generated from within a native thread in
the native class itself. I will give the following...
|
by: Lee Moore |
last post by:
I am trying to develop a threaded function to create a dataset from an
Oracle database. When querying an elaborate view, queries take a while. I
would like to place and animated wait dialog up...
|
by: fniles |
last post by:
I am having problem with thread. I have a Session class with public string
variable (called Message) that I set from my Main program. In the session
class it checks for the value of Message...
|
by: sandy |
last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory',
within my class Directory (Can you already smell disaster?)
Each Directory can have subdirectories so I thought to put these...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |