C#Àï¹ØÓÚ¶¨Ê±Æ÷Àà
¹ØÓÚC#ÖÐtimerÀà ÔÚC#Àï¹ØÓÚ¶¨Ê±Æ÷Àà¾ÍÓÐ3¸ö
1.¶¨ÒåÔÚSystem.Windows.FormsÀï
2.¶¨ÒåÔÚSystem.Threading.TimerÀàÀï
3.¶¨ÒåÔÚSystem.Timers.TimerÀàÀï
System.Windows.Forms.TimerÊÇÓ¦ÓÃÓÚWinFormÖеģ¬ËüÊÇͨ¹ýWindowsÏûÏ¢»úÖÆÊµÏֵģ¬ÀàËÆÓÚVB»òDelphiÖеÄTimer¿Ø¼þ£¬ÄÚ²¿Ê¹ÓÃAPI SetTimerʵÏֵġ£ËüµÄÖ÷ҪȱµãÊǼÆÊ±²»¾«È·£¬¶øÇÒ±ØÐëÓÐÏûϢѻ·£¬Console Application(¿ØÖÆÌ¨Ó¦ÓóÌÐò)ÎÞ·¨Ê¹Óá£
System.Timers.TimerºÍSystem.Threading.Timer·Ç³£ÀàËÆ£¬ËüÃÇÊÇͨ¹ý.NET Thread PoolʵÏֵģ¬ÇáÁ¿£¬¼ÆÊ±¾«È·£¬¶ÔÓ¦ÓóÌÐò¡¢ÏûϢûÓÐÌØ±ðµÄÒªÇó¡£System.Timers.Timer»¹¿ÉÒÔÓ¦ÓÃÓÚWinForm£¬Íêȫȡ´úÉÏÃæµÄTimer¿Ø¼þ¡£ËüÃǵÄȱµãÊDz»Ö§³ÖÖ±½ÓµÄÍÏ·Å£¬ÐèÒªÊÖ¹¤±àÂë¡£
Àý£º
ʹÓÃSystem.Timers.TimerÀà
System.Timers.Timer t = new System.Timers.Timer(10000);//ʵÀý»¯TimerÀ࣬ÉèÖüä¸ôʱ¼äΪ10000ºÁÃ룻
t.Elapsed += new System.Timers.ElapsedEventHandler(theout);//µ½´ïʱ¼äµÄʱºòÖ´ÐÐʼþ£»
t.AutoReset = true;//ÉèÖÃÊÇÖ´ÐÐÒ»´Î£¨false£©»¹ÊÇÒ»Ö±Ö´ÐÐ(true)£»
t.Enabled = true;//ÊÇ·ñÖ´ÐÐSystem.Timers.Timer.Elapsedʼþ£»
public void theout(object source, System.Timers.ElapsedEventArgs e)
{
MessageBox.Show("OK!");
}
Ïà¹ØÎĵµ£º
ÔÚasp.net開發ÖУ¬經³£會Óõ½áą́ºÍǰ̨µÄ½»»¥£¬¾Í´Ë總結ÁËÒ»點c#ºÍjavascriptÏ໥²Ù×÷µÄ·½·¨
¡¡¡¡1.ÔÚáą́c#´ú碼ÖÐ調ÓÃjacascriptµÄ·½·¨
¡¡¡¡javascript´ú碼£º
¡¡¡¡<script type="text/javascript" language="javascript">
¡¡¡¡function test()
¡ ......
asp.net(c#)ÍøÒ³Ìø×ªÆßÖÖ·½·¨Ð¡½á
·¢²¼Ê±¼ä£º2009-11-25 11:13:03
¡¡¡¡1.Response.Redirect("http://www.yayiba.com",false);
¡¡¡¡Ä¿±êÒ³ÃæºÍÔÒ³Ãæ¿ÉÒÔÔÚ2¸ö·þÎñÆ÷ÉÏ£¬¿ÉÊäÈëÍøÖ·»òÏà¶Ô·¾¶¡£ºóÃæµÄboolֵΪÊÇ·ñÍ£Ö¹Ö´Ðе±Ç°Ò³¡£
Ìø×ªÏòеÄÒ³Ãæ£¬Ô´°¿Ú±»´úÌæ¡£"
ä¯ÀÀÆ÷ÖеÄURLΪз¾¶¡£
:Response.Redirect·½ ......
ÔÚдsqlÓï¾äʱ£¬Ò»°ã¶¼ÊÇÒ»¾ä½â¾ö£¬´ÓÀ´Ã»Ïë¹ý˵£¬°ÑsqlÓï¾ä²ð¿ªÀ´Ð´¡£
ÀýÈçÏÂÃæÕâ¾ä£º string readstring = "select * from ʵÀý where ʵÀýID='"+eid+"'";
È»ºóÖ´ÐÐ Myconnection();
DataSet ds = new DataSet();
OleD ......
µ±ÔÚC#ÓïÑÔÖУ¬Á¬½ÓsqlÊý¾Ý¿âµÄʱºò£¬³£Óõ½sqlconnection½¨Á¢ÓëÊý¾Ý¿âµÄÁ¬½Ó¡£ Óï·¨ÈçÏ£º
String sqlcon = "***";//ÕâÀïÊÇÒ»¸ö×Ö·û´®£¬¾ßÌå¸úÊý¾Ý¿âµÄÑéÖ¤·½Ê½Óйء£
//sql server Éí·ÝÑéÖ¤ Á¬½Ó×Ö·û´®
private string ConnstrSqlServer = "server=·þÎñÆ÷Ãû³ ......