Board index » Visual Studio » Overlapped IO and CSyncObject

Overlapped IO and CSyncObject

Visual Studio236
Hello,



Is there an updated OVERLAPPED structure that

uses CSyncObject (CEvent) instead of

antique HANDLE ?



Or even a constructor for CEvent

to create one from an existing

HANDLE.



Of course I can create a CEvent object

and use the HANDLE operator....hmmm



There seems to be some funny mixing

of AFX and antique HANDLE calls

to do overlaped file IO using

AFX...



Any insights would be appreciated,



Pete


-
 

Re:Overlapped IO and CSyncObject

No. Remember that CSyncObject is an MFC layer on top of the operating system, which

actually has no idea whether you are using MFC, VB, Delphi, awk, perl, or whatever to

write the code that calls it. So you have to use the HANDLE value to the call.



You could extract the HANDLE from the CSyncObject and pass it in, which solves part of

your problem. But most of us don't trust the MFC synchronization objects anyway, and avoid

them (you would not BELIEVE the bugs I've found in them; in one version the SetEvent

checked an unsynchronized Boolean value to determine if the SetEvent really needed to be

done. Of course, it never set the event more than once, because it set the Boolean. Never

mind that the ReserEvent was done in a completely separate process!) I wouldn't trust an

MFC synchronization object as far as I could throw an IBM mainframe.



Remember: the operating system DOES NOT CARE what language you write in. It would make no

more sense to use a CSyncObject in an OVERLAPPED structure than it would make to use a

CWnd object to tell the kernel what to do with a window.



MFC does not pretend to satisfy all possible interfaces to the kernel. It does not really

support I/O completion ports, asynchronous I/O, callback functions, and a lot of other

kernel-level concepts.



I would be more concerned if this actually reprsented a problem worth worrying about.

joe



On Fri, 23 Jul 2004 18:25:23 GMT, pw <a6c21487@telus.net>wrote:



Quote
Hello,



Is there an updated OVERLAPPED structure that

uses CSyncObject (CEvent) instead of

antique HANDLE ?



Or even a constructor for CEvent

to create one from an existing

HANDLE.



Of course I can create a CEvent object

and use the HANDLE operator....hmmm



There seems to be some funny mixing

of AFX and antique HANDLE calls

to do overlaped file IO using

AFX...



Any insights would be appreciated,



Pete



Joseph M. Newcomer [MVP]

email: newcomer@flounder.com

Web: www.flounder.com">www.flounder.com

MVP Tips: www.flounder.com/mvp_tips.htm">www.flounder.com/mvp_tips.htm

-