T
Tom Vandeplas
Hi all,
When using an asynchronous API call (in my case WriteFileEx) in a thread it
seems to become blocking instead of non-blocking (see details below). Can
somebody explain me what is happening here...
Details:
I wrote a simple program that is able to do very fast async writes to disk.
For that I used the WriteFileEx API call which is by nature asynchronous. At
first I wrote a simple console app to verify the concept, it worked fine.
Once integrated it in my main app, it became a lot slower. After
investigating a little, it seemed that the call became blocking instead of
non-blocking. The main difference between the console app and my main app is
that I put the calling method inside a worker thread. Does anybody know how
to fix this, make it async again ?
Kindest regards,
Tom
PS: My API call goes like this:
[DllImport("kernel32.dll", SetLastError=true)]
public unsafe static extern int WriteFileEx ( IntPtr hFile,
byte[] lpBuffer,
int nNumberOfBytesToWrite,
NativeOverlapped * lpOverlapped,
IOCompletionCallback lpCompletionRoutine);
When using an asynchronous API call (in my case WriteFileEx) in a thread it
seems to become blocking instead of non-blocking (see details below). Can
somebody explain me what is happening here...
Details:
I wrote a simple program that is able to do very fast async writes to disk.
For that I used the WriteFileEx API call which is by nature asynchronous. At
first I wrote a simple console app to verify the concept, it worked fine.
Once integrated it in my main app, it became a lot slower. After
investigating a little, it seemed that the call became blocking instead of
non-blocking. The main difference between the console app and my main app is
that I put the calling method inside a worker thread. Does anybody know how
to fix this, make it async again ?
Kindest regards,
Tom
PS: My API call goes like this:
[DllImport("kernel32.dll", SetLastError=true)]
public unsafe static extern int WriteFileEx ( IntPtr hFile,
byte[] lpBuffer,
int nNumberOfBytesToWrite,
NativeOverlapped * lpOverlapped,
IOCompletionCallback lpCompletionRoutine);