New test.
[mono.git] / mcs / class / System.Web / Test / TestMonoWeb / AsyncModule.cs
1 using System;
2 using System.Web;
3
4 namespace TestMonoWeb
5 {
6         /// <summary>
7         /// Summary description for AsyncModule.
8         /// </summary>
9         public class AsyncModule : IHttpModule
10         {
11                 HttpApplication _app;
12
13                 public void Init(HttpApplication app) {
14                         app.AddOnPreRequestHandlerExecuteAsync(
15                                 new BeginEventHandler(this.BeginPreHandlerExecute), 
16                                 new EndEventHandler(this.EndPreHandlerExecute));
17
18                         _app = app;
19                 }
20
21                 IAsyncResult BeginPreHandlerExecute(Object source, EventArgs e, AsyncCallback cb, Object extraData) {
22                         ((HttpApplication) source).Context.Response.Write("AsyncModule.BeginPreHandlerExecute()<br>\n");
23
24                         AsynchOperation asynch = new AsynchOperation(cb, _app.Context, extraData);
25                         asynch.StartAsyncWork();
26                         return asynch;
27                 }
28                 
29                 void EndPreHandlerExecute(IAsyncResult ar) {
30                         ((AsynchOperation) ar).Context.Response.Write("AsyncModule.EndPreHandlerExecute()<br>\n");
31                 }               
32
33                 public void Dispose() {
34                 }
35         }
36 }