时间:2021-07-01 10:21:17 帮助过:4人阅读
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="response.aspx.cs" Inherits="_Default" Async="true" AsyncTimeout="30" EnableSessionState="False"%>
if (Request.Form.Count>0)
{
if (Request.Form["type"] == "loop")
{
ChatTask task = new ChatTask(this.Context);
task._chatNow = this.ChatNow;//有新的消息的回调方法,即为通知处理,这个时候释放掉连接
string user = Request.Form["user"].Trim();
PageAsyncTask async = new PageAsyncTask(new BeginEventHandler(task.OnBegin), new EndEventHandler(task.OnEnd), new EndEventHandler(task.OnTimeout), user);
Page.RegisterAsyncTask(async);
Page.ExecuteRegisteredAsyncTasks();//异步执行
}
}
具体代码和实现效果请参见范例。
附件:
范例程序: ReverseAjaxChat范例.rar