"Handle does not support asynchronous operations"
Posted on 2004-08-11
I'm using a mixture between managed code and pure C# ;) ...
So I'm opening a file (actually it's not a file but an USB HID) with:
HidHandle = CreateFile(
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
I get a valid Handle and I use this handle to:
FileStream fs = new FileStream(xx,FileAccess.ReadWrite,true,7,true);
where xx is this handle (previously converted to a IntPtr)
Now I can use
to get one block of data (7 bytes)
but when I want to read a second time, I get the message:
"An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Handle does not support asynchronous operations. The parameters to the FileStream constructor may need to be changed to indicate that the handle was opened synchronously (that is, it was not opened for overlapped I/O)."
The Overlapped Flag is defined as:
private const int FILE_FLAG_OVERLAPPED = 0x40000000;
Does anyone have any idea ?