Click here to Skip to main content
15,900,973 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionImplementing SMTP in MFC Pin
QuickDeveloper3-Apr-06 19:52
QuickDeveloper3-Apr-06 19:52 
AnswerRe: Implementing SMTP in MFC Pin
Joe Woodbury3-Apr-06 20:00
professionalJoe Woodbury3-Apr-06 20:00 
AnswerRe: Implementing SMTP in MFC Pin
Hamid_RT3-Apr-06 21:12
Hamid_RT3-Apr-06 21:12 
QuestionWNetAddConnection2() Pin
shadrach_india3-Apr-06 19:01
shadrach_india3-Apr-06 19:01 
QuestionCMenu owner Drawing Pin
Naveen3-Apr-06 18:32
Naveen3-Apr-06 18:32 
AnswerRe: CMenu owner Drawing Pin
Hamid_RT3-Apr-06 19:15
Hamid_RT3-Apr-06 19:15 
AnswerRe: CMenu owner Drawing Pin
Ștefan-Mihai MOGA4-Apr-06 0:11
professionalȘtefan-Mihai MOGA4-Apr-06 0:11 
QuestionTimers Pin
chetan2101833-Apr-06 17:53
chetan2101833-Apr-06 17:53 
Hi everyone,

I am trying to develop a Dialog based application for a device communicating through RS 232 serial Port. The serial port receives the new samples of data every 100 milli seconds. I am trying to display the message in a textbox and write the data to a file. For this purpose, i created a thread for receiving data. I am using a Timer with 100 milli seconds for Updating the textbox and writing the received data to the file.

The Problem now i am facing is, when the file gets full, i am trying to display error message and stop the timer. But Timer is not getting stopped by KillTimer().Timer continues in the running state.

BOOL MyDlg::OnInitDialog()
{
....
...
ConfigureSerialPort();
AfxBeginThread(Serial, NULL,THREAD_PRIORITY_NORMAL,0,0,NULL);
return TRUE;
}

void CMyDlg::OnClickStart()
{
fp = fopen(file_name,"a");
if (NULL == fp)
{
MessageBox ("Error Writing File",NULL, MB_OK|MB_ICONSTOP);
KillTimer(m_nTimer);
}
m_nTimer = SetTimer(1, 100, NULL);
fprintf(fp,"%d\n",status);
}

void CMyDlg::OnTimer(UINT nIDEvent)
{
OnClickStart();
CDialog::OnTimer(nIDEvent);
}

UINT Serial(LPVOID pParam)
{
while(1)
{
DWORD dwBytesTransferred;
ReadFile (hPort,
inbuf,
60,
&dwBytesTransferred,
NULL);
Sleep(100);
}
return TRUE;
}

Please help me regarding this problem. I am New to MultiThreading Concepts.

Thanks.

Chetan.



Helping others satisfies you...
AnswerRe: Timers Pin
Nibu babu thomas3-Apr-06 18:25
Nibu babu thomas3-Apr-06 18:25 
GeneralRe: Timers Pin
chetan2101833-Apr-06 18:46
chetan2101833-Apr-06 18:46 
GeneralRe: Timers Pin
Nibu babu thomas3-Apr-06 18:52
Nibu babu thomas3-Apr-06 18:52 
GeneralRe: Timers Pin
chetan2101833-Apr-06 18:59
chetan2101833-Apr-06 18:59 
GeneralRe: Timers Pin
Nibu babu thomas3-Apr-06 19:02
Nibu babu thomas3-Apr-06 19:02 
AnswerRe: Timers Pin
Laxman Auti3-Apr-06 18:28
Laxman Auti3-Apr-06 18:28 
GeneralRe: Timers Pin
Nibu babu thomas3-Apr-06 18:33
Nibu babu thomas3-Apr-06 18:33 
AnswerRe: Timers Pin
Anilkumar K V3-Apr-06 20:09
Anilkumar K V3-Apr-06 20:09 
Questionread and write email in lotus notes Pin
rcao3-Apr-06 17:20
rcao3-Apr-06 17:20 
Questionusing process to look for hwnd Pin
zt97883-Apr-06 17:10
zt97883-Apr-06 17:10 
AnswerRe: using process to look for hwnd Pin
Stephen Hewitt3-Apr-06 17:46
Stephen Hewitt3-Apr-06 17:46 
GeneralRe: using process to look for hwnd Pin
zt97883-Apr-06 19:13
zt97883-Apr-06 19:13 
GeneralRe: using process to look for hwnd Pin
Stephen Hewitt3-Apr-06 19:16
Stephen Hewitt3-Apr-06 19:16 
GeneralRe: using process to look for hwnd Pin
zt97883-Apr-06 19:43
zt97883-Apr-06 19:43 
GeneralRe: using process to look for hwnd Pin
Stephen Hewitt3-Apr-06 19:53
Stephen Hewitt3-Apr-06 19:53 
Questioncode like this. Pin
sting_lee3-Apr-06 16:27
sting_lee3-Apr-06 16:27 
AnswerRe: code like this. Pin
Rick York3-Apr-06 17:44
mveRick York3-Apr-06 17:44 

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.