Click here to Skip to main content
15,914,820 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: post message from one dialog to another dialog Pin
David Crow10-Sep-07 5:38
David Crow10-Sep-07 5:38 
Questionpostmessage and send message Pin
bhogavalli suresh9-Sep-07 23:33
bhogavalli suresh9-Sep-07 23:33 
AnswerRe: postmessage and send message Pin
Russell'9-Sep-07 23:37
Russell'9-Sep-07 23:37 
AnswerRe: postmessage and send message Pin
ThatsAlok10-Sep-07 2:53
ThatsAlok10-Sep-07 2:53 
AnswerRe: postmessage and send message Pin
David Crow10-Sep-07 5:39
David Crow10-Sep-07 5:39 
QuestionAccessing the serial port in multithreading [modified] Pin
Cedric Moonen9-Sep-07 22:39
Cedric Moonen9-Sep-07 22:39 
GeneralRe: Accessing the serial port in multithreading Pin
Matthew Faithfull9-Sep-07 22:51
Matthew Faithfull9-Sep-07 22:51 
GeneralRe: Accessing the serial port in multithreading Pin
Cedric Moonen9-Sep-07 23:40
Cedric Moonen9-Sep-07 23:40 
Matthew Faithfull wrote:
Hmm, a tricky one. I would consider having the same thread doing the reading and writing, taking it's orders from a queue and prioritising writing over reading.


We considered that but that wouldn't solve the problem: if there is nothing to write, we will read the serial port (even if there is nothing coming in) and the read will return immediately. If there is still nothing to write, we'll read directly again. Thus, we'll have a busy loop that consumes CPU cycles (and which is an above average priority thread, so it will screw everything).


Matthew Faithfull wrote:
In other words do the very short timeout read 1 or 2 msecs then if there is anything to write, write it otherwise go around again and do another read or sleep if no read is required.


Well, that's the problem: we don't want to wait for 1 or 2 msec (waiting for the read operation to complete) or to sleep some msec in between.


Matthew Faithfull wrote:
Remember on Windows Mobile your reader/writer thread should not have a raised priority if you do this sort of thing or no other thread will ever get a look in as the threading is purely priority based rather than preemptively time sliced.


If the read and write threads are just waiting (like a blocking read), then this problem is automatically solved. And that's exactly what we want to do: give the read and write thread high priority but they just wait until something happen (data has been received or data need to be transmitted).

But I think we found another way to deal with the problem: bu using WaitCommEvent[^]. In the loop that read the port, we simply call this function before the read. Once the function returns, we check if the event was because of data coming in. If that's the case, then we read the data. So, this loop simply waits until data comes in.


Cédric Moonen
Software developer

Charting control [v1.2]

GeneralRe: Accessing the serial port in multithreading Pin
Matthew Faithfull9-Sep-07 23:43
Matthew Faithfull9-Sep-07 23:43 
AnswerRe: Accessing the serial port in multithreading Pin
Roger Stoltz10-Sep-07 0:23
Roger Stoltz10-Sep-07 0:23 
QuestionDrive's last formatted date/time Pin
vipin_nvk9-Sep-07 22:00
vipin_nvk9-Sep-07 22:00 
QuestionDraw on the none-client area [modified] Pin
kcynic9-Sep-07 21:47
kcynic9-Sep-07 21:47 
AnswerRe: Draw on the none-client area Pin
Jason Teagle9-Sep-07 22:14
Jason Teagle9-Sep-07 22:14 
GeneralRe: Draw on the none-client area Pin
kcynic9-Sep-07 22:49
kcynic9-Sep-07 22:49 
AnswerRe: Draw on the none-client area Pin
Naveen9-Sep-07 22:32
Naveen9-Sep-07 22:32 
GeneralRe: Draw on the none-client area Pin
kcynic9-Sep-07 22:50
kcynic9-Sep-07 22:50 
GeneralRe: Draw on the none-client area Pin
Naveen9-Sep-07 23:15
Naveen9-Sep-07 23:15 
GeneralRe: Draw on the none-client area Pin
kcynic10-Sep-07 16:31
kcynic10-Sep-07 16:31 
QuestionChild-process without parents Pin
baerten9-Sep-07 21:31
baerten9-Sep-07 21:31 
AnswerRe: Child-process without parents [modified] Pin
Stephen Hewitt9-Sep-07 22:26
Stephen Hewitt9-Sep-07 22:26 
GeneralRe: Child-process without parents Pin
baerten9-Sep-07 22:50
baerten9-Sep-07 22:50 
GeneralRe: Child-process without parents Pin
Stephen Hewitt10-Sep-07 14:37
Stephen Hewitt10-Sep-07 14:37 
GeneralRe: Child-process without parents Pin
baerten10-Sep-07 21:52
baerten10-Sep-07 21:52 
GeneralRe: Child-process without parents Pin
Stephen Hewitt10-Sep-07 22:05
Stephen Hewitt10-Sep-07 22:05 
GeneralRe: Child-process without parents Pin
baerten10-Sep-07 22:27
baerten10-Sep-07 22: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.