public override void EndWrite(IAsyncResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            if (!IsAsync)
            {
                base.EndWrite(result);
            }

            if (!(result is VfsStreamAsyncResult))
            {
                throw new ArgumentException("Invalid IAsyncResult object", "result");
            }

            VfsStreamAsyncResult asyncResult = (VfsStreamAsyncResult)result;

            if (asyncResult.Done)
            {
                throw new InvalidOperationException("EndWrite already called");
            }
            asyncResult.Done = true;

            while (!asyncResult.IsCompleted)
            {
                MainContext.Iteration();
            }

            if (asyncResult.Exception != null)
            {
                throw asyncResult.Exception;
            }
        }
		public VfsStreamAsyncResult BeginWrite ()
		{
			asyncResult = new VfsStreamAsyncResult (state);
			Async.Write (handle, out buffer[offset], (uint)count, new AsyncWriteCallback (AsyncWrite));
			return asyncResult;
		}
 public VfsStreamAsyncResult BeginWrite()
 {
     asyncResult = new VfsStreamAsyncResult(state);
     Async.Write(handle, out buffer[offset], (uint)count, new AsyncWriteCallback(AsyncWrite));
     return(asyncResult);
 }
		public VfsStreamAsyncResult BeginRead ()
		{
			asyncResult = new VfsStreamAsyncResult (state);
			Async.Read (handle, out buffer[offset], (uint)count, new AsyncReadCallback (AsyncRead));
			return asyncResult;
		}