Click here to Skip to main content
15,916,835 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: select the home directory for the .ini files Pin
dilara semerci9-Aug-10 20:12
dilara semerci9-Aug-10 20:12 
AnswerRe: select the home directory for the .ini files Pin
David Crow10-Aug-10 3:30
David Crow10-Aug-10 3:30 
Question[Solved]How to parse a URL in C++ using sscanf() [modified] Pin
Elsie9-Aug-10 4:05
Elsie9-Aug-10 4:05 
AnswerRe: How to parse a URL in C++ using sscanf() Pin
Maximilien9-Aug-10 4:10
Maximilien9-Aug-10 4:10 
QuestionRe: How to parse a URL in C++ using sscanf() Pin
David Crow9-Aug-10 4:12
David Crow9-Aug-10 4:12 
AnswerRe: How to parse a URL in C++ using sscanf() Pin
Elsie9-Aug-10 4:16
Elsie9-Aug-10 4:16 
QuestionStub dll fails to find entry point [modified] Pin
VentsyV9-Aug-10 4:04
VentsyV9-Aug-10 4:04 
AnswerRe: Stub dll fails to find entry point Pin
Richard MacCutchan9-Aug-10 22:16
mveRichard MacCutchan9-Aug-10 22:16 
QuestionCascading specific windows in a MFC MDI application Pin
Elsie9-Aug-10 3:56
Elsie9-Aug-10 3:56 
AnswerRe: Cascading specific windows in a MFC MDI application Pin
Niklas L9-Aug-10 8:09
Niklas L9-Aug-10 8:09 
QuestionCombo Box Pin
dilara semerci9-Aug-10 3:03
dilara semerci9-Aug-10 3:03 
AnswerRe: Combo Box Pin
Maximilien9-Aug-10 4:08
Maximilien9-Aug-10 4:08 
GeneralRe: Combo Box Pin
dilara semerci9-Aug-10 4:19
dilara semerci9-Aug-10 4:19 
GeneralRe: Combo Box Pin
Maximilien9-Aug-10 5:29
Maximilien9-Aug-10 5:29 
QuestionUsing Activex controls (Designed in vb6) in vc++ Pin
rrthangavel9-Aug-10 2:30
rrthangavel9-Aug-10 2:30 
AnswerRe: Using Activex controls (Designed in vb6) in vc++ Pin
Elsie9-Aug-10 3:59
Elsie9-Aug-10 3:59 
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 

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.