MVC3 integrated, with some changes to make it compile on Mono and with Razor2
[mono-project.git] / mcs / class / System.Web.Mvc3 / Mvc / Async / SimpleAsyncResult.cs
blobfb001d426a9c288a8663ad98ed2e769599d83100
1 namespace System.Web.Mvc.Async {
2 using System;
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 {
16 get {
17 return _asyncState;
21 // ASP.NET IAsyncResult objects should never expose a WaitHandle due to potential deadlocking
22 public WaitHandle AsyncWaitHandle {
23 get {
24 return null;
28 public bool CompletedSynchronously {
29 get {
30 return _completedSynchronously;
34 public bool IsCompleted {
35 get {
36 return _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;
47 _isCompleted = true;
49 if (callback != null) {
50 callback(this);