fxl31 / mybatisnet

Automatically exported from code.google.com/p/mybatisnet
0 stars 0 forks source link

Use IBatisNet develop a Web application, in fact, started to automate tasks in multi-threaded processing, processed once every 10 minutes, but the following problem #39

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
To initialize DaoManager in Global.asax
C # code
protected void Application_start (...) {
   / / Initialize DaoManager
   WZW.IBatisNet.SqlMap.DaoConfig.GetInstance (). InitBaseDaoManager ();

   / / Record system startup log
   Biz.SysLogBiz.GetInstance (). AddLog ("", Const.SYS_LOG_LOG_TYPE_SYSTEM_START, "system startup success!");

   Biz.AutoRunBiz.GetInstance ();

}

Automatic processing procedure is as follows:

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

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

        public AutoRunBiz ()
        {
            / / Timer is running
            Thread th = new Thread (new ThreadStart (this.Run));
            th.Start ();
        }

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

                / / Executed once every 10 minutes
                Thread.Sleep (600000);
            }
        }
    }

Found that the system logs the following questions:

System startup system startup 2009-10-26 19:40:19
System startup system startup 2009-10-26 19:29:56
System startup system startup 2009-10-26 19:19:47

Every 10 minutes will be initialized once DaoManager

Description Global.asax the Application_Start every 10 minutes performed once, 
if not the automatic task processing, only the execution time Application_start

Master please help?

Original issue reported on code.google.com by wanghui...@gmail.com on 3 Feb 2012 at 12:33