Click here to Skip to main content
15,887,291 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSimulate post at webpage Pin
Daniel Strigl14-Sep-05 22:10
Daniel Strigl14-Sep-05 22:10 
QuestionRenaming Tree Nodes Pin
laiju14-Sep-05 20:41
laiju14-Sep-05 20:41 
QuestionWhat is the Anotomy of Encarta? Pin
shoaibnawaz14-Sep-05 20:30
shoaibnawaz14-Sep-05 20:30 
AnswerRe: What is the Anotomy of Encarta? Pin
vikas amin14-Sep-05 21:36
vikas amin14-Sep-05 21:36 
QuestionHow to print the page for right of screen !!! Pin
ebinaini14-Sep-05 19:51
ebinaini14-Sep-05 19:51 
QuestionHow to wait for thread & if no response within time abort it Pin
karmendra_js14-Sep-05 19:32
karmendra_js14-Sep-05 19:32 
AnswerRe: How to wait for thread & if no response within time abort it Pin
PJ Arends14-Sep-05 19:52
professionalPJ Arends14-Sep-05 19:52 
GeneralRe: How to wait for thread & if no response within time abort it Pin
karmendra_js14-Sep-05 21:05
karmendra_js14-Sep-05 21:05 
Thanks, thanks a lot for that info. I implemented it as follows.

///////////////////////////////////////////////////////////
DWORD WINAPI WriteMdsDataPseudoThread( IN LPVOID vThreadParm )
{ //Calling the member function in seperate thread.
CDevice* pThreadParam = ( CDevice* ) vThreadParm;
pThreadParam->write_mds_data_thread();
return 1;
}

unsigned short CDevice::write_mds_data(unsigned char *message )
{
msg=message;

ExecuteWriteThread();//call to start the thread

return 1;
}

int CDevice::ExecuteWriteThread()
{
HANDLE hThread = NULL;
DWORD dwThreadID = 0;
int nTimeout = 1000;

try
{
//Creating the thread
hThread = CreateThread( NULL, // Pointer to thread security attributes
0, // Initial thread stack size, in bytes
WriteMdsDataPseudoThread,
this, // The argument for the new thread is a pointer to CDevice object
0, // Creation flags
&dwThreadID ); // Pointer to returned thread identifier
}
catch( CException* /* pException */ )
{
AfxMessageBox("Write Error. Please retry");
return false;
}

WaitForSingleObject(hThread, nTimeout);

DWORD dwWaitReturn;
GetExitCodeThread(hThread, &dwWaitReturn);

if(STILL_ACTIVE == dwWaitReturn)
CloseHandle(hThread);
return 1;
}
///////////////////////////////////////////////////////////

but i am not sure, that the thread is terminated releasing all the resources.

And my host application still hangs.

can you help.

Thanks again.

Who is your hero? Only one who helps you, who cares about everyone problems.............Do you wanna be HERO?
GeneralRe: How to wait for thread & if no response within time abort it Pin
HumanOsc14-Sep-05 21:59
HumanOsc14-Sep-05 21:59 
GeneralRe: How to wait for thread & if no response within time abort it Pin
David Crow15-Sep-05 7:43
David Crow15-Sep-05 7:43 
GeneralRe: How to wait for thread & if no response within time abort it Pin
ThatsAlok15-Sep-05 18:15
ThatsAlok15-Sep-05 18:15 
GeneralRe: How to wait for thread & if no response within time abort it Pin
David Crow16-Sep-05 2:18
David Crow16-Sep-05 2:18 
AnswerRe: How to wait for thread & if no response within time abort it Pin
Roger Stoltz14-Sep-05 21:45
Roger Stoltz14-Sep-05 21:45 
GeneralRe: How to wait for thread & if no response within time abort it Pin
karmendra_js14-Sep-05 22:04
karmendra_js14-Sep-05 22:04 
GeneralRe: How to wait for thread & if no response within time abort it Pin
HumanOsc14-Sep-05 22:40
HumanOsc14-Sep-05 22:40 
AnswerRe: How to wait for thread & if no response within time abort it Pin
karmendra_js14-Sep-05 23:03
karmendra_js14-Sep-05 23:03 
GeneralRe: How to wait for thread & if no response within time abort it Pin
Roger Stoltz14-Sep-05 23:22
Roger Stoltz14-Sep-05 23:22 
GeneralRe: How to wait for thread & if no response within time abort it Pin
karmendra_js14-Sep-05 23:43
karmendra_js14-Sep-05 23:43 
GeneralRe: How to wait for thread & if no response within time abort it Pin
Roger Stoltz15-Sep-05 1:53
Roger Stoltz15-Sep-05 1:53 
QuestionAbout CString : Plz Send Urgently Pin
parims14-Sep-05 19:08
parims14-Sep-05 19:08 
AnswerRe: About CString : Plz Send Urgently Pin
karmendra_js14-Sep-05 19:45
karmendra_js14-Sep-05 19:45 
AnswerRe: About CString : Plz Send Urgently Pin
prasad_som14-Sep-05 19:51
prasad_som14-Sep-05 19:51 
AnswerRe: About CString : Plz Send Urgently Pin
kakan14-Sep-05 20:03
professionalkakan14-Sep-05 20:03 
AnswerRe: About CString : Plz Send Urgently Pin
vikas amin15-Sep-05 1:11
vikas amin15-Sep-05 1:11 
JokeRe: About CString : Plz Send Urgently Pin
prasad_som15-Sep-05 2:16
prasad_som15-Sep-05 2:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.