Click here to Skip to main content
15,887,350 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: EOF for cygwin executable? Pin
9ine2-Mar-06 5:02
9ine2-Mar-06 5:02 
AnswerRe: EOF for cygwin executable? Pin
Ryan Binns1-Mar-06 17:19
Ryan Binns1-Mar-06 17:19 
GeneralRe: EOF for cygwin executable? Pin
9ine1-Mar-06 22:15
9ine1-Mar-06 22:15 
GeneralRe: EOF for cygwin executable? Pin
Ryan Binns1-Mar-06 22:50
Ryan Binns1-Mar-06 22:50 
GeneralRe: EOF for cygwin executable? Pin
9ine1-Mar-06 23:38
9ine1-Mar-06 23:38 
QuestioncFile assert Pin
act_x1-Mar-06 5:58
act_x1-Mar-06 5:58 
AnswerRe: cFile assert Pin
David Crow1-Mar-06 6:58
David Crow1-Mar-06 6:58 
AnswerRe: cFile assert Pin
Joe Woodbury1-Mar-06 10:45
professionalJoe Woodbury1-Mar-06 10:45 
It's likely that thread A had not yet actually opened the file, or at least assigned m_hFile to the file handle, before thread B runs. Since there is an OS call, it is very likely the open operation is triggering a sleep operation which, in turn, is causing thread B to run if it has been created by that point.

I suggest not creating thread B until thread A has opened the file. An alternative is to have thread B wait on an event that will be signalled once thread A has opened the file.

A critical section should be used for read/write/close operations, but are a potential problem here since thread B could get it's time slice before thread A even enters its critical section to open the file.

Another option to look at is for thread B to open and close the file.

Also note that when you close the file, thread B must either be terminated (wait on it's handle, then close the file) or should check if the file handle is valid before performing the operation.

Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke

QuestionInitializing IXMLDOMTextPtr Pin
hanno251-Mar-06 5:26
hanno251-Mar-06 5:26 
QuestionMultiDocTemplate initialization question Pin
camoguard1-Mar-06 5:00
camoguard1-Mar-06 5:00 
AnswerRe: MultiDocTemplate initialization question Pin
camoguard1-Mar-06 5:31
camoguard1-Mar-06 5:31 
QuestionHowto make a system modal application Pin
whatever891-Mar-06 4:46
whatever891-Mar-06 4:46 
AnswerRe: Howto make a system modal application Pin
David Crow1-Mar-06 5:32
David Crow1-Mar-06 5:32 
QuestionHow show a Bitmap Pin
Alfius791-Mar-06 4:20
Alfius791-Mar-06 4:20 
AnswerRe: How show a Bitmap Pin
Hamid_RT1-Mar-06 4:25
Hamid_RT1-Mar-06 4:25 
GeneralRe: How show a Bitmap Pin
Alfius791-Mar-06 4:30
Alfius791-Mar-06 4:30 
QuestionRe: How show a Bitmap Pin
David Crow1-Mar-06 4:27
David Crow1-Mar-06 4:27 
AnswerRe: How show a Bitmap Pin
Alfius791-Mar-06 21:05
Alfius791-Mar-06 21:05 
GeneralRe: How show a Bitmap Pin
David Crow2-Mar-06 3:09
David Crow2-Mar-06 3:09 
GeneralRe: How show a Bitmap Pin
Alfius792-Mar-06 5:06
Alfius792-Mar-06 5:06 
Questionmix code Vc++ Pin
_tasleem1-Mar-06 4:07
_tasleem1-Mar-06 4:07 
QuestionTypecast _bstr_t to int? Pin
hanno251-Mar-06 3:53
hanno251-Mar-06 3:53 
QuestionRe: Typecast _bstr_t to int? Pin
David Crow1-Mar-06 4:01
David Crow1-Mar-06 4:01 
AnswerRe: Typecast _bstr_t to int? Pin
walter761-Mar-06 4:29
walter761-Mar-06 4:29 
GeneralRe: Typecast _bstr_t to int? Pin
hanno251-Mar-06 5:23
hanno251-Mar-06 5:23 

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.