internal void CallUserCallback()
{
// Convenience method for me, since I have to do this in a number
// of places in the buffering code for fake IAsyncResults.
// AsyncFSCallback intentionally does not use this method.
if (_userCallback != null) {
// Call user's callback on a threadpool thread.
// Set completedSynchronously to false, since it's on another
// thread, not the main thread.
_completedSynchronously = false;
ThreadPool.QueueUserWorkItem(new WaitCallback(CallUserCallbackWorker));
}
else {
_isComplete = true;
if (_waitHandle != null)
_waitHandle.Set();
}
}
internal static FileStreamAsyncResult CreateBufferedReadResult(int numBufferedBytes, AsyncCallback userCallback, Object userStateObject, bool isWrite) { FileStreamAsyncResult asyncResult = new FileStreamAsyncResult(numBufferedBytes, userCallback, userStateObject, isWrite); asyncResult.CallUserCallback(); return(asyncResult); }