下面的代碼內(nèi)容是關(guān)于C# 控制asp.net網(wǎng)站自動(dòng)更新數(shù)據(jù)的代碼,應(yīng)該是對(duì)碼農(nóng)們也有好處。
成都創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、大觀網(wǎng)絡(luò)推廣、微信小程序定制開(kāi)發(fā)、大觀網(wǎng)絡(luò)營(yíng)銷、大觀企業(yè)策劃、大觀品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);成都創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供大觀建站搭建服務(wù),24小時(shí)服務(wù)熱線:18982081108,官方網(wǎng)址:www.cdcxhl.com
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;using System.Threading;
namespace OKGO.Web
{
public class TestTimer
{static int n = 0;
public static Timer GlobalTimer = new Timer(new TimerCallback(GlobalTimer_ToDo), null, Timeout.Infinite, Timeout.Infinite); GlobalTimer.Interval = 10; GlobalTimer.Enabled = true; static void GlobalTimer_ToDo(object obj) { n = n + 1; if (n == 2) { System.Data.SqlClient.SqlDataReader dataReader = null; try { System.IO.StreamReader sr = null; string str=string.Empty; dataReader = OKGO.DataAccess.SQLServer.ChannelProvider.Provider.GetAllRoleName(); while (dataReader.Read() && dataReader.HasRows) { try { System.Net.WebResponse myTemp = temp.GetResponse(); sr = new System.IO.StreamReader(myTemp.GetResponseStream(), System.Text.Encoding.GetEncoding("utf-8")); str = sr.ReadToEnd(); System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument(); xmldoc.LoadXml(str); System.Xml.XmlNode nodes = xmldoc.SelectSingleNode("Result"); if (Rolename == "") continue; OKGO.DataAccess.SQLServer.ChannelProvider.Provider.GetUpdateRoleName(int.Parse(dataReader["UserName"].ToString()), Rolename, RolenameTime); sr.Close(); sr.Dispose(); sr.Close(); } catch (Exception ex) { throw ex; } } } catch (Exception exc) { if (dataReader != null) { dataReader.Close(); dataReader.Dispose(); } throw exc; } finally { if (dataReader != null) { dataReader.Close(); dataReader.Dispose(); } n = 0; } } } public static void Start(long a, long b) { GlobalTimer.Change(a, b); } public static void Stop() { GlobalTimer.Change(Timeout.Infinite, Timeout.Infinite); } }
}