ASP.netÖÐTimerºÍWebServiceµÄʹÓÃ
ʾÀýÒ»
ÔÚGlobal.asax.csÎļþÖУº
protected void Application_Start(Object sender, EventArgs e)
{
System.Timers.Timer timer1 = new System.Timers.Timer();
timer1.Interval = 50000; // 50000 ºÁÃë = 50Ãë
timer1.Elapsed += new System.Timers.ElapsedEventHandler(timer1_Elapsed);
timer1.AutoReset = true;
timer1.Enabled = true;
timer1.Start();
}
void timer1_Elapsed(object source, System.Timers.ElapsedEventArgs e)
{
// ÔÚÕâÀï¼ÓÉ϶ÁÈ¡Êý¾Ý¿âµÄ´úÂë¾Í¿ÉÒÔʵÏÖºǫ́·þÎñ¶¨Ê±·ÃÎÊÊý¾Ý¿âµÄ¹¦ÄÜ£¬¸Ã¹¦ÄܶÔÓÚʵÏÖÎļþ½â
//Ëø¡¢ÂÛ̳¶¨Ê±Í³¼ÆµÈºÜÓÐÓá£
}
ʾÀý¶þ
ͨ¹ýÔÚÍøÕ¾µÄGlobal.asaxµÄApplication_Start·½·¨ÖÐ
¼ÓÈ붨ʱÆ÷ ¶¨Ê±µ÷ÓÃWebService
¸ÃWebServiceµÄÒ»¸ö·½·¨ ¸ºÔðÔÚºǫ́
ÏòÊý¾Ý¿âµÄij¸ö±í¼ÓÈëÊý¾Ý
²½Ö裺
1.ͨ¹ýVS н¨Ò»¸öÍøÕ¾
2.¼ÓÈëGlobal
Ïà¹ØÎĵµ£º
Ê×Ò³£º
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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 ......
×î½üÅöµ½Ò»ÎÊÌ⣬ÐèÒªÔÚASP.NetºÍJavaScriptÖд«µÝÊý¾Ý¡£¾ßÌåµÄÐèÇóÊÇÕâÑùµÄ£¬Ò³Ãæpostbackºó½«»áload JS£¬µ«ÊÇÐèÒª¼Çס֮ǰij¸ö״̬£¬Õâ¸ö״̬ÊÇÖ¸JSµÄ״̬£¬Ò²¾ÍÊÇ˵load JSºó£¬»¹Òª¼Çס֮ǰµÄ״̬£¬¶ø²»Êǻص½Ä¬ÈϵÄ״̬¡£
Ò»¿ªÊ¼ÏëÁ˺ܶà°ì·¨£¬µ«¶¼²»³É¹¦£¬ºóÀ´ÎÊÁËÎÊͬÊ£¬·¢ÏÖ¿ÉÒÔͨ¹ýÒþ²ØµÄ±íµ¥ÔªËØÀ´´«µÝÊý¾Ý£¬ËùÒ ......
public class PageBase:System.Web.UI.Page
{
public PageBase()
{
//
// TODO: Add constructor logic here
//
}
protected override void InitializeCulture()
{
// ......
ĸ°æÒ³Ãæ
-- н¨Ò»Ä¸°æÒ³Ãæ
-- ÔÚÊʵ±Î»ÖüÓÈë´úÂ룺
<asp:ContentPlaceHolder ID="ContentPlaceHolder3" runat="server">
...ÕâÖ®¼äµÄÄÚÈÝÈç¹ûûÓÐContentÄÚÈÝ£¬½«»áµÃµ½ÏÔʾ£»
...Èç¹ûÓÐContentÄÚÈÝ£¬½«»á±»ContentÄÚÈÝÌæ»»µô
</asp:ContentPlaceHolder>
ContentÒ³Ãæ
-- н¨Ò»WEB´°Ìå
-- ÔÚÊʵ± ......