2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / System.Web / Test / TestMonoWeb / AsyncOperation.cs
1 using System;\r
2 using System.Threading;\r
3 using System.Web;\r
4 \r
5 namespace TestMonoWeb\r
6 {\r
7         class AsynchOperation : IAsyncResult {\r
8                 private bool _completed;\r
9                 private Object _state;\r
10                 private AsyncCallback _callback;\r
11                 private HttpContext _context;\r
12 \r
13                 bool IAsyncResult.IsCompleted { get { return _completed; } }\r
14                 WaitHandle IAsyncResult.AsyncWaitHandle { get { return null; } }\r
15                 Object IAsyncResult.AsyncState { get { return _state; } }\r
16                 bool IAsyncResult.CompletedSynchronously { get { return false; } }\r
17 \r
18                 public HttpContext Context {\r
19                         get {\r
20                                 return _context;\r
21                         }\r
22                 }\r
23 \r
24                 public AsynchOperation(AsyncCallback callback, HttpContext context, Object state) {\r
25                         _callback = callback;\r
26                         _context = context;\r
27                         _state = state;\r
28                         _completed = false;\r
29                 }\r
30 \r
31                 public void StartAsyncWork() {\r
32                         ThreadPool.QueueUserWorkItem(new WaitCallback(DoSomething), null /*workItemState*/);\r
33                 }\r
34 \r
35                 private void DoSomething(Object workItemState) {\r
36                         // Just for testing..\r
37                         Thread.Sleep(100);\r
38                         _completed = true;\r
39                         _callback(this);\r
40                 }\r
41         }\r
42 }\r