Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用IBatisNet开发一个Web应用程序,其实启动了多线程来自动执行任务处理,每10分钟处理一次,但出现了如下问题 #38

Open
GoogleCodeExporter opened this issue Mar 14, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

在Global.asax中初始化DaoManager
C# code
protected void Application_start(...){
   //初始化DaoManager
   WZW.IBatisNet.SqlMap.DaoConfig.GetInstance().InitBaseDaoManager();

   //记录系统启动日志
   Biz.SysLogBiz.GetInstance().AddLog("", Const.SYS_LOG_LOG_TYPE_SYSTEM_START, "系统启动成功!");

   Biz.AutoRunBiz.GetInstance();

}



自动处理程序如下:

C# code
public class AutoRunBiz
    {
        private static AutoRunBiz instance = null;

        public static AutoRunBiz GetInstance()
        {
            if (instance == null)
            {
                instance = new AutoRunBiz();
            }
            return instance;
        }

        public AutoRunBiz()
        {
            //定时运行
            Thread th = new Thread(new ThreadStart(this.Run));
            th.Start();
        }

        private void Run()
        {
            while (true)
            {
                Biz.MakePageBiz.GetInstance().MakeIndex();

                //每10分钟执行一次
                Thread.Sleep(600000);
            }
        }
    }




发现系统日志有如下问题:

系统启动 系统启动成功! 2009-10-26 19:40:19   
系统启动 系统启动成功! 2009-10-26 19:29:56   
系统启动 系统启动成功! 2009-10-26 19:19:47   

即每10分钟会初始化一次DaoManager

说明Global.asax中的Application_start每10分钟执行了一次,如果不��
�自动任务处理,则只会执行一次Application_start,

请高手帮忙?


Original issue reported on code.google.com by wanghui...@gmail.com on 2 Feb 2012 at 1:05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant