473,395 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Passaggio puntatore di classe in CreateThread

Salve a tutti,
sto creando una applicazione che istanzia un thread al quale viene
passato come argomento il puntatore ad una classe che contiene molte
funzioni alcune delle quali devono essere necessariamente static. Non
trovando nessun esempio in giro e non sapendo come referenziare le
variabili globali di classe CIndiceSP nelle funzioni static della
classe stessa ho utilizzato questo metodo che non mi crea nessun
errore di compilazione ma non mi sembra molto pratico.
Volevo sapere se per voi è corretto il modo in cui ho impostato il
codice o se usualmente si programma diversamente.

Allego il codice sperando possa essere chiaro.
Grazie in anticipo

#include "IndiceSP.h"

CAlbero albero;
CIndiceSP* p_indsp;

int main ( void )
{
p_indsp = new CIndiceSP(INFOContext, albero);

HANDLE IhThread = CreateThread(
NULL,
0,

(LPTHREAD_START_ROUTINE)(SubscribeIndiceSP),
&p_indsp,
0,
&ThreadIdInd);

do
{
GetExitCodeThread(IhThread, &exitCode);
Sleep(1000);
} while (exitCode==STILL_ACTIVE);

{....}

}

//--- funzione del main -------------//
DWORD SubscribeIndiceSP(LPVOID arg)
{
CIndiceSP* p_indsp = (CIndiceSP*)arg;

int errcode = p_indsp->Subscribe();

if (errcode != 1 )
{
printf( "Sottoscrizione INDICE_SP fallita\n" );
ExitThread(EXIT_FAILURE);
}
else
{
printf( "Sottoscrizione INDICE_SP attiva!!!!\n" );
}

return 0;
}

////////CLASSE CIndiceSP /////////////////////////////////////
#include "IndiceSP.h"

extern CIndiceSP* p_indsp; ////è corretto?

CIndiceSP::CIndiceSP(AMI_Context_t Contesto, CAlbero& a)
{
INFOContext = Contesto;
albero = &a;

gAppISP = APPINFO_ERROR;
status_ind = AMI_FAILURE;

}

DWORD CIndiceSP::Subscribe() //funzione static
{

if ( p_indsp->gAppISP != AMI_SUCCESS ) ///gAppISP: variabile di
classe gAppISP
{
printf( "\nCIndiceSP.Subscribe() failed\n" );
return EXIT_FAILURE;
}

else
{
return EXIT_SUCCESS;
}

printf ( "Stop CIndiceSP.Subscribe\n" );
}
Jul 23 '05 #1
3 2609
lamilla wrote:
Salve a tutti,


Sorry, this group accepts English posts only, and only on standard
C++. CreateThread is a Windows function, so please go to an italian
Windows group.

PS.
Use English comments, please, even in code you do not expect to
leave your company. Code in English is more valuable because there
are more people who can read English.

Regards,
Michiel Salters

Jul 23 '05 #2
lamilla wrote:
Salve a tutti,
sto creando [..]


You probably need to post to it.comp.lang.c++ ... This NG speaks English.
And since I don't know the rules of the it.comp.* NGs, I cannot say
anything about the topicality of your CreateThread question there. I can
say, however, that here it's OT (even if asked in English) because the C++
_language_ doesn't have threads in it (yet). You might want to look into
reading 'microsoft.public.vc.language' or some other Microsoft forum like
'comp.os.ms-windows.programmer.win32'.

V
Jul 23 '05 #3
msalters wrote:
lamilla wrote:
Salve a tutti,

Sorry, this group accepts English posts only, and only on standard
C++. CreateThread is a Windows function, so please go to an italian
Windows group.

PS.
Use English comments, please, even in code you do not expect to
leave your company. Code in English is more valuable because there
are more people who can read English.


I wonder about the latest statistics on the subject. There quite a few
people on the planet who can read Spanish and Chinese. I hope you're not
suggesting that if there are more Spanish-reading folks out there, we all
should switch to writing our comments in Spanish...

V
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: grigoo | last post by:
bonjour a tous je me presente a vous::: greg dit le grigoo sur le web ,,etudiant en bioinformatique a montreal et jusqu au cou dans notre language prefere....java. et biojava.. et je suis en un...
1
by: phark52 | last post by:
My main app calls LoadLibrary() to load a DLL, which calls CreateThread(). This does NOT return NULL and I get a thread ID. However, ThreadProc never gets executed when this code is in the DLL. It...
5
by: Vinayak Raghuvamshi | last post by:
Threads created using the CreateThread API used to leak memory if you accesed any crt methods within the thread proc. we used to use _beginthread to work around this issue. Does anyone know if...
3
by: raj | last post by:
Hi, I just want to know the difference between thread created by CreateThread and AfxBeginThread function. I got one problem when using the CreateThread. The appliction malfunction while using the...
3
by: mccanaveras | last post by:
Hello, I need to implement a Thread in a Visual C++ 6.0 application. I've never done this, then I've been investigating, but I don't have any properly solution. One of them is use CWinThread...
0
by: liamacheung | last post by:
Hi, I am designing a GUI application using a VC++ 2005 Form template. I have created a thread function external to the class containing the form. I can successfully create the thread and run...
5
by: eagerlearner | last post by:
Hallo, when I use class and I put one of the member function as the CreateThread argument, I keep getting the compile error in Visual Studio 2005. #include <windows.h> class X { public:...
3
by: sevak316 | last post by:
This must be an easy question. I am trying to create a thread in windows. I am using C as my language. I am trying to pass a function to the CreateThread function to create a thread. My...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.