Click here to Skip to main content
15,909,898 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Why it doesn't work? Pin
Monty29-Jan-04 0:48
Monty29-Jan-04 0:48 
GeneralRe: Why it doesn't work? Pin
SiddharthAtw9-Jan-04 19:07
SiddharthAtw9-Jan-04 19:07 
GeneralProperty Sheet ShortCuts Pin
Prakash Nadar8-Jan-04 19:16
Prakash Nadar8-Jan-04 19:16 
GeneralVisual C++ NET Pin
java_jedi8-Jan-04 18:44
java_jedi8-Jan-04 18:44 
GeneralRe: Visual C++ NET Pin
Antti Keskinen8-Jan-04 20:02
Antti Keskinen8-Jan-04 20:02 
QuestionTBCD ?? Pin
Jagadeesh VN8-Jan-04 18:37
Jagadeesh VN8-Jan-04 18:37 
GeneralSerial communication and how to timeout Pin
J.B.8-Jan-04 18:33
J.B.8-Jan-04 18:33 
GeneralRe: Serial communication and how to timeout Pin
Antti Keskinen8-Jan-04 20:11
Antti Keskinen8-Jan-04 20:11 
You could, for example, create a global-level boolean variable, if you're not using classes. Then create a timer for the thread, and in the thread's message processing function, handle the WM_TIMER event. When the timer event is launched, the boolean is set to TRUE, which causes the while loop to exit.

Another option would be to use the Sleep function. This function will cause a thread to suspend until the time is elapsed, then continue the program execution from the next line of code. You could create a local variable, say an integer, which would go from 0 to 3, and during each while-loop iteration, the port is tested, then the thread sleeps for 1 second and increases the integer. The while-loop will automatically exit after 3 seconds.

The latter implementation only attempts to read the port at 1 second intervals, so it is not entirely reliable. If you need a more reliable system, decrease the sleep time and increase the iteration amount. An amount of going from 0...100 would already offer you the possibility to check the port at 30 ms intervals, if you aim for a 3 second time-out.

The advantage of the sleep function is the lack of the timer: there will be no extra message-processing needed. Know, however, that during the sleep time, the thread will not process any messages at all.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: Serial communication and how to timeout Pin
J.B.9-Jan-04 1:26
J.B.9-Jan-04 1:26 
GeneralRe: Serial communication and how to timeout Pin
Antti Keskinen9-Jan-04 3:49
Antti Keskinen9-Jan-04 3:49 
GeneralRe: Serial communication and how to timeout Pin
J.B.9-Jan-04 4:09
J.B.9-Jan-04 4:09 
GeneralRe: Serial communication and how to timeout Pin
SiddharthAtw8-Jan-04 21:41
SiddharthAtw8-Jan-04 21:41 
GeneralRe: Serial communication and how to timeout Pin
J.B.9-Jan-04 1:29
J.B.9-Jan-04 1:29 
GeneralPlease help me!! Pin
Ryulee8-Jan-04 18:16
Ryulee8-Jan-04 18:16 
GeneralRe: Please help me!! Pin
David Crow9-Jan-04 3:32
David Crow9-Jan-04 3:32 
GeneralRe: Please help me!! Pin
Ryulee11-Jan-04 17:42
Ryulee11-Jan-04 17:42 
GeneralRe: Please help me!! Pin
David Crow12-Jan-04 2:32
David Crow12-Jan-04 2:32 
GeneralRe: Please help me!! Pin
Ryulee14-Jan-04 17:11
Ryulee14-Jan-04 17:11 
QuestionHow can i get this event what the virtual address of my process be changed by the windows?? Pin
zx_sanjin8-Jan-04 15:14
zx_sanjin8-Jan-04 15:14 
AnswerRe: How can i get this event what the virtual address of my process be changed by the windows?? Pin
l a u r e n8-Jan-04 17:04
l a u r e n8-Jan-04 17:04 
GeneralGrabbing messages while busy Pin
Ernesto D.8-Jan-04 15:07
Ernesto D.8-Jan-04 15:07 
GeneralRe: Grabbing messages while busy Pin
Christian Graus8-Jan-04 15:15
protectorChristian Graus8-Jan-04 15:15 
GeneralRe: Grabbing messages while busy Pin
l a u r e n8-Jan-04 17:06
l a u r e n8-Jan-04 17:06 
GeneralRe: Grabbing messages while busy Pin
Tim Smith9-Jan-04 4:08
Tim Smith9-Jan-04 4:08 
GeneralRe: Grabbing messages while busy Pin
Ernesto D.8-Jan-04 18:27
Ernesto D.8-Jan-04 18:27 

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.