[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / class / System.Web / Test / TestMonoWeb / AsyncHandler.cs
blob1affcf4c095a0c7f608907b7c4b8fb82c7c5a8fd
1 using System;
2 using System.Threading;
3 using System.Web;
5 namespace TestMonoWeb {
6 /// <summary>
7 /// Summary description for AsyncHandler.
8 /// </summary>
9 public class AsyncHandler : IHttpAsyncHandler {
10 private HttpContext _context;
11 public bool IsReusable {
12 get {
13 //To enable pooling, return true here.
14 //This keeps the handler in memory.
15 return false;
19 public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) {
20 AsynchOperation asynch = new AsynchOperation(cb, context, null);
21 asynch.StartAsyncWork();
23 context.Response.Write("AsyncHandler.BeginProcessRequest<br>\n");
24 context.Response.Flush();
26 //Signal the application that asynchronous
27 //processing is being performed.
28 SomeResult asynchForBegin = new SomeResult();
30 //Processing is not synchronous.
31 asynchForBegin.SetSynch(false);
33 //Processing is not complete.
34 asynchForBegin.SetCompleted(false);
36 _context = context;
38 return new SomeResult();
41 public void EndProcessRequest(IAsyncResult result) {
42 _context.Response.Write("AsyncHandler.EndProcessRequest<br>\n");
45 //This method is required but is not called.
46 public void ProcessRequest(HttpContext context) {
49 }//end class
51 public class SomeResult : IAsyncResult {
54 An instance of this class is returned to the application.
55 This class lets the application know how the BeginEventHandler method has been handled. The application checks the CompletedSynchronously method.
58 private bool _blnIsCompleted = false;
59 private Mutex myMutex = null;
60 private Object myAsynchStateObject = null;
61 private bool _blnCompletedSynchronously = false;
63 public void SetCompleted(bool blnTrueOrFalse) {
64 _blnIsCompleted = blnTrueOrFalse;
67 public void SetSynch(bool blnTrueOrFalse) {
68 _blnCompletedSynchronously = blnTrueOrFalse;
71 public bool IsCompleted {
73 This is not called by the application. However, set it to true.
75 get {
76 return _blnIsCompleted;
80 public WaitHandle AsyncWaitHandle {
81 //The application does not call this method.
82 get {
83 return myMutex;
87 public Object AsyncState {
88 //The application does not call this method because
89 //null is passed in as the last parameter to BeginEventHandler.
90 get {
91 return myAsynchStateObject;
95 public bool CompletedSynchronously {
96 //The application wants to know if this is synchronous.
97 //Return true if the Begin method was called synchronously.
98 get {
99 return _blnCompletedSynchronously;