Suggestion (feel free to ignore, since you know more about the context of
your application):
How about not disabling the buttons, and pumping the messages, and just
alerting the user with a red sign (not a modal message box of course) that
they should wait, and clear that red sign when the comms is done?

Because (a) that wouldn't prevent the CPU hogging,

A modal dialog won't take any cpu cycles unless they sit there and move it around, click in the wrong places, etc...


and (b) because users
never obey what they're told and will always try and click something anyway

With a modal dialog they don't have a choice. They can click in other places of the app, but it doesn't do anything except "flash" at them and "boing" to let them know they have to deal with the dialog first.


(Just checking...)  Is rsThreadData.hPortHandle opened with
FILE_FLAG_OVERLAPPED?  Is the hEvent member of the OVERLAPPED object
properly created as a manual-reset event?

Yes for the first...

but no for the second... can you explain why I should have manual reset? I
think this was one I didn't know what I should do, so I chose automatic.

A manual reset basically leaves the sync object as "set" until you specify it to be reset. Automatic means as soon as a waiting thread is triggered by you setting it it will automatically be reset. So it all depends on your design. Here's one case where you would want manual. If you have 5 threads all waiting on a auto sync object and you want all 5 threads to wake up when the object is set it won't work because the first thread that wakes up will automatically reset the sync object and the other 4 threads won't ever "see" that the sync object was actually set. So you'd need a manual sync object and (depending on how you wanted to handle it) a counter that counted up each thread that is awoke, when the counter is 5 you reset the counter to 0 and the sync object.


I think it may, if you have any more thoughts about that inner loop in
WaitForRX() - Daniel suggested I should simply wait for the handle in the
OVERLAPPED structure to become signalled, I guess you would concur?

I do. Do a wait with your timeout as the value, then check the return value to see if it returned because it hit the timeout or because the handle was signaled.



_______________________________________________ msvc mailing list [email protected] See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.

Reply via email to