The code below creates a thread on a global function (ReadChildOutpu t):
CreateThread(NU LL, 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(NU LL, 0, this->ReadChildOutpu t, NULL, 0, &ThreadId);
Thanks,
Chris 2 1889
Chris LaJoie wrote: The code below creates a thread on a global function (ReadChildOutpu t):
CreateThread(NU LL, 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(NU LL, 0, this->ReadChildOutpu t, 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 (ReadChildOutpu t):
CreateThread(NU LL, 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(NU LL, 0, this->ReadChildOutpu t, 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**********@vq k.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 is ok ?
or there is other way to do that ?
|
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 puposes only and is not
normally visable to the user.) The Thread function is actually in the Form
class.
Now.. What I am seeing is that when I create an instance of this Class
Library's Form, which starts the worker thread, it seems to hose up...
|
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 puposes only and is not
normally visable to the user.) The Thread function is actually in the Form
class.
Now.. What I am seeing is that when I create an instance of this Class
Library's Form, which starts the worker thread, it seems to hose up...
|
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
//what i need to add , so only 1 thread per time can access this class in
MultiThread app.
| |
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 runtime error,
" Attempting to call into managed code without transitioning out first.
Do not attempt to run managed code inside low-level native
extensibility points, such as the vectored exception handler, since
doing so can cause corruption...
|
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 while the query runs. I
don't know much about threading, so bear with me. The following code
contains a class that works fine when threading is not used, but fails to
return a dataset when I execute the threading code. Any help would be
appreciated....
|
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 while inside it's "read loop"
waiting for data from the client. In the main program, I check to see if
the Message member has been cleared before changing its value, that way you
know it has been written by the
|
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 in an
array. The application compiles but aborts without giving me any useful
information.
What I suspect is happening is infinite recursion. Each Directory
object creates an array of Subdirectories each of which has an array of...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |