private static unsafe void WriteToBlobAsync(CloudPageBlob blob, IntPtr sourceAddress, ulong destinationAddress, uint numBytesToWrite, IOCompletionCallback callback, IAsyncResult asyncResult) { // Even though Azure Page Blob does not make use of Overlapped, we populate one to conform to the callback API Overlapped ov = new Overlapped(0, 0, IntPtr.Zero, asyncResult); NativeOverlapped * ovNative = ov.UnsafePack(callback, IntPtr.Zero); UnmanagedMemoryStream stream = new UnmanagedMemoryStream((byte *)sourceAddress, numBytesToWrite); blob.BeginWritePages(stream, (long)destinationAddress, null, ar => { try { blob.EndWritePages(ar); } // I don't think I can be more specific in catch here because no documentation on exception behavior is provided catch (Exception e) { Trace.TraceError(e.Message); // Is there any documentation on the meaning of error codes here? The handler suggests that any non-zero value is an error // but does not distinguish between them. callback(1, numBytesToWrite, ovNative); } callback(0, numBytesToWrite, ovNative); }, asyncResult); }