1 namespace System.Web.Mvc.Async {
3 using System.Threading;
5 internal sealed class SimpleAsyncResult : IAsyncResult {
7 private readonly object _asyncState;
8 private bool _completedSynchronously;
9 private volatile bool _isCompleted;
11 public SimpleAsyncResult(object asyncState) {
12 _asyncState = asyncState;
15 public object AsyncState {
21 // ASP.NET IAsyncResult objects should never expose a WaitHandle due to potential deadlocking
22 public WaitHandle AsyncWaitHandle {
28 public bool CompletedSynchronously {
30 return _completedSynchronously;
34 public bool IsCompleted {
40 // Proper order of execution:
41 // 1. Set the CompletedSynchronously property to the correct value
42 // 2. Set the IsCompleted flag
43 // 3. Execute the callback
44 // 4. Signal the WaitHandle (which we don't have)
45 public void MarkCompleted(bool completedSynchronously, AsyncCallback callback) {
46 _completedSynchronously = completedSynchronously;
49 if (callback != null) {