ASP.NET中Timer的运用

原文链接: http://www.cnblogs.com/heroking2000/archive/2009/10/23/1588916.html

在Global.asax中

ContractedBlock.gif ExpandedBlockStart.gif Code
private static readonly ILog log = LogManager.GetLogger(typeof(Global));
        Timer logTimer 
= null;
        
protected void Application_Start(object sender, EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
{
            
            XmlConfigurator.Configure();
            logTimer 
= new Timer(new TimerCallback(Log), null01000);
        }

        
protected void Application_End(object sender, EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
{
            
if (logTimer != null)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
{
                logTimer.Dispose();
            }

        }

        
private void Log(object obj)
ExpandedBlockStart.gifContractedBlock.gif        
{
            log.Debug(
"this programe is running!");
        }

转载于:https://www.cnblogs.com/heroking2000/archive/2009/10/23/1588916.html

猜你喜欢

转载自blog.csdn.net/weixin_30496431/article/details/94967985
今日推荐