AjaxAsyncHttpHandler.cs
上传用户:szgaoree
上传日期:2009-01-05
资源大小:74k
文件大小:2k
- using System;
- using System.Reflection;
- using System.Web;
- using System.Threading;
- using System.Web.SessionState;
- namespace AjaxPro
- {
- public delegate void ImDone();
- public class AjaxAsyncHttpHandler : IHttpAsyncHandler
- {
- private IAjaxProcessor p;
- private HttpContext ctx = null;
- private AsyncCallback acb = null;
- private SimpleResult sr = new SimpleResult();
- private Thread th = null;
- private ImDone mcb = null;
- public AjaxAsyncHttpHandler(IAjaxProcessor p) : base()
- {
- this.p = p;
- }
-
- private void OnDone()
- {
- acb(sr);
- }
- #region IHttpAsyncHandler Members
- public IAsyncResult BeginProcessRequest(HttpContext context, System.AsyncCallback cb, object extraData)
- {
- ctx = context;
- acb = cb;
- // Create the delegate to be called when complete
- mcb = new ImDone(OnDone);
- IntPtr token = System.Security.Principal.WindowsIdentity.GetCurrent().Token;
- // Set up the thread object
- AjaxProcHelper m = new AjaxProcHelper(p, mcb, token);
- th = new Thread(new ThreadStart(m.Run));
- th.Start();
- return sr;
- }
- public void EndProcessRequest(IAsyncResult result)
- {
- int i = 0;
- }
- #endregion
- #region IHttpHandler Members
- public void ProcessRequest(HttpContext context)
- {
- // TODO: Add AjaxAsyncHttpHandler.ProcessRequest implementation
- }
- public bool IsReusable
- {
- get
- {
- // TODO: Add AjaxAsyncHttpHandler.IsReusable getter implementation
- return false;
- }
- }
- #endregion
- }
- public class AjaxAsyncHttpHandlerSession : AjaxAsyncHttpHandler, IRequiresSessionState
- {
- public AjaxAsyncHttpHandlerSession(IAjaxProcessor p) : base(p) { }
- }
- public class AjaxAsyncHttpHandlerSessionReadOnly : AjaxAsyncHttpHandler, IReadOnlySessionState
- {
- public AjaxAsyncHttpHandlerSessionReadOnly(IAjaxProcessor p) : base(p) { }
- }
- }