62,072
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Reflection;
using System.Xml;
using System.Data.SqlClient;
using System.Messaging;
using System.Text.RegularExpressions;
using System.Net;
using System.Data.OleDb;
[AjaxPro.AjaxNamespace("AJ")]
public partial class ajax_ajaxpro_MultiThread : System.Web.UI.Page
{
System.Web.SessionState.HttpSessionState _Session;
protected void Page_Load(object sender, EventArgs e)
{
Response.Expires = -100;
Response.Cache.SetCacheability(HttpCacheability.NoCache);
AjaxPro.Utility.RegisterTypeForAjax(typeof(ajax_ajaxpro_MultiThread), this);
}
[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)]
public String GetSessionValue()
{
if (Session["a"] != null) return Session["a"].ToString();
else return "-----";
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["a"] = "0";
System.Threading.Thread NewTh = new System.Threading.Thread(new System.Threading.ThreadStart(this.Update));
NewTh.Start();
ClientScript.RegisterStartupScript(this.GetType(), "a", "window.setInterval(showvalue, 1000);", true);
}
void Update()
{
try
{
Session["a"] = "10";
System.Threading.Thread.Sleep(3000);
Session["a"] = "30";
System.Threading.Thread.Sleep(3000);
Session["a"] = "50";
System.Threading.Thread.Sleep(3000);
Session["a"] = "80";
System.Threading.Thread.Sleep(3000);
Session["a"] = "100";
System.Threading.Thread.Sleep(3000);
}
catch
{ }
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页 </title>
<style>
*
{
font:menu;
}
.CalendarArrow
{
CURSOR: pointer;font-weight:bold;
}
</style>
<script type="text/javascript">
function showvalue()
{
document.getElementById('div1').innerHTML= AJ.GetSessionValue().value;
}
</script>
</head>
<body >
<form id="form1" runat="server">
<asp:Button ID="btnNext" runat="server" Text="确定" OnClick="Button1_Click" />
<div id="div1"> </div>
</form>
</body>
</html>