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

C / C++ / MFC

 
GeneralRe: Using Activex controls (Designed in vb6) in vc++ Pin
rrthangavel9-Aug-10 5:51
rrthangavel9-Aug-10 5:51 
QuestionSMBus Pin
mab099-Aug-10 1:23
mab099-Aug-10 1:23 
QuestionGetLastInputInfo error Pin
Pryabu8-Aug-10 21:44
Pryabu8-Aug-10 21:44 
AnswerRe: GetLastInputInfo error Pin
_AnsHUMAN_ 8-Aug-10 22:12
_AnsHUMAN_ 8-Aug-10 22:12 
GeneralRe: GetLastInputInfo error Pin
Pryabu8-Aug-10 22:17
Pryabu8-Aug-10 22:17 
AnswerRe: GetLastInputInfo error Pin
Niklas L8-Aug-10 23:07
Niklas L8-Aug-10 23:07 
AnswerRe: GetLastInputInfo error Pin
KingsGambit8-Aug-10 23:10
KingsGambit8-Aug-10 23:10 
QuestionCloseHandle() freezes the program... Pin
learningvisualc8-Aug-10 19:27
learningvisualc8-Aug-10 19:27 
Hi all,

I have made a application in which i am reading a port using CreateFile() API with FILE_FLAG_OVERLAPPED parameter as NULL. This all processing i have done in worker thread. Everything is working fine but the problem is when i am trying to close the process i am using CloseHandle API and when the control enters in CloseHandle() the program frezees and there is no option of closing it. The code i am using is as below
void CUse::ThreadStart()
{
	ThreadHandle = AfxBeginThread(Thread , (LPVOID) this);
}
UINT Thread(LPVOID pParam)
{
        serial_handle = CreateFile(port_arg, GENERIC_READ | GENERIC_WRITE,
                   0, NULL, OPEN_EXISTING,NULL,NULL);
        .
        .
        .
        .
        //Code for reading the port

}
void CUse::OnCancel() 
{
	ThreadHandle->SuspendThread();
	if(MessageBox("Are you sure to stop the process?","ReadingPort",MB_YESNO)==6)
	{	
		ZeroMemory(rxBuffer,128);
		ZeroMemory(rxtemp,256);
		tempid=0;
		CloseHandle(serial_handle);
		CDialog::OnCancel();
		::TerminateThread(ThreadHandle->m_hThread,0);
	}
	else
		ThreadHandle->ResumeThread();
}


How to resolve this problem or any alternate way of doing it...
Thanks in advance
AnswerRe: CloseHandle() freezes the program... Pin
«_Superman_»8-Aug-10 19:33
professional«_Superman_»8-Aug-10 19:33 
AnswerRe: CloseHandle() freezes the program... Pin
Iain Clarke, Warrior Programmer8-Aug-10 21:20
Iain Clarke, Warrior Programmer8-Aug-10 21:20 
GeneralRe: CloseHandle() freezes the program... Pin
SRIVATHSAN VIJAYA22-Apr-15 0:33
SRIVATHSAN VIJAYA22-Apr-15 0:33 
QuestionHow to do fast Zip in c++? Pin
002comp8-Aug-10 18:20
002comp8-Aug-10 18:20 
AnswerRe: How to do fast Zip in c++? Pin
N a v a n e e t h8-Aug-10 18:46
N a v a n e e t h8-Aug-10 18:46 
GeneralRe: How to do fast Zip in c++? Pin
elchupathingy8-Aug-10 19:18
elchupathingy8-Aug-10 19:18 
GeneralRe: How to do fast Zip in c++? Pin
002comp8-Aug-10 21:11
002comp8-Aug-10 21:11 
GeneralRe: How to do fast Zip in c++? Pin
002comp9-Aug-10 0:16
002comp9-Aug-10 0:16 
GeneralRe: How to do fast Zip in c++? Pin
Moak10-Aug-10 13:13
Moak10-Aug-10 13:13 
QuestionHow to check the NULL iterator? Pin
DevelopmentNoob8-Aug-10 17:26
DevelopmentNoob8-Aug-10 17:26 
AnswerRe: How to check the NULL iterator? [modified] PinPopular
Niklas L8-Aug-10 19:44
Niklas L8-Aug-10 19:44 
AnswerRe: How to check the NULL iterator? Pin
Moak8-Aug-10 21:39
Moak8-Aug-10 21:39 
AnswerRe: How to check the NULL iterator? Pin
Aescleal8-Aug-10 22:22
Aescleal8-Aug-10 22:22 
QuestionwaveOutOpen returning no message?? Pin
AmbiguousName8-Aug-10 2:45
AmbiguousName8-Aug-10 2:45 
AnswerRe: waveOutOpen returning no message?? Pin
Richard MacCutchan8-Aug-10 2:54
mveRichard MacCutchan8-Aug-10 2:54 
GeneralRe: waveOutOpen returning no message?? Pin
AmbiguousName8-Aug-10 4:30
AmbiguousName8-Aug-10 4:30 
GeneralRe: waveOutOpen returning no message?? Pin
Luc Pattyn8-Aug-10 4:58
sitebuilderLuc Pattyn8-Aug-10 4:58 

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.