dahall / Vanara

A set of .NET libraries for Windows implementing PInvoke calls to many native Windows APIs with supporting wrappers.
MIT License
1.75k stars 190 forks source link

OverlappedAsyncBaseResult does not make processed bytes available. #443

Closed mateli closed 3 months ago

mateli commented 4 months ago

When using OverlappedAsyncBase for read and write operation, getting the number of written/read bytes is very useful.

I am thinking something like this: asyncResult.Complete(true, (int)code); >> asyncResult.Complete(true, (int)code, bytes);

internal void Complete(bool synch = false, int error = 0, uint bytes = 0)
{
    CompletedSynchronously = synch;
    errorCode = error;
        processedBytes = bytes;
    if (IsCompleted) return;
        IsCompleted = true;
        lock (lockObj)
        {
            evt?.Set();
            AsyncCallback?.Invoke(this);
        }
    }
}
dahall commented 3 months ago

Added to 4.0.0 beta