我的需求:设计了两个线程,两个线程分别调用各自的方法,程序启动后,无论什么操作,各自休眠1分钟然后不断调用各自的方法进行查询实时数据
现在的问题:程序启动,线程没有被调用,打断点无法命中。
请问各位大佬们,如何处理?尝试过在web.config配置handlers节点,无效。
代码如下(try  catch代码有点儿多,只列出了结构):using System;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Web;
using System.Threading;
using System.Text;namespace .Application.OMIS
{
    public class IIAPThread
    {
        private static Thread Update = new Thread(new ThreadStart(IIAPThread.thread1));//线程1
        
        private static Thread JudgeNewData = new Thread(new ThreadStart(IIAPThread.thread2));//线程2
        public static void thread1()
        {
            while (true)//每间隔1分钟调用循环内部方法进行查询更新数据
            {
                Fun_Update_IIAP_LastYearRemainingNumber();
                Thread.Sleep(60000);
            }
        }        //计算可申请额度值
        private static void Fun_Update_IIAP_LastYearRemainingNumber()
        {
            try
            {
            }
             catch (Exception eErr)
             {
             }
         }        public static void thread2()
        {
            while (true)//每间隔1分钟调用循环内部方法进行查询更新数据
            {
                Fun_JudgeNewData_IIAP_EnterpriseApplicationData();
                Thread.Sleep(60000);
            }
        }        //对企业新申请数据进行处理 
        private static void Fun_JudgeNewData_IIAP_EnterpriseApplicationData()
        {
            try
            {}
            catch (Exception exp)
             {
                       
             }
       }
                                                
                      
                          

解决方案 »

  1.   

     private static Thread Update = new Thread(new ThreadStart(IIAPThread.thread1));//线程1
    这是创建了一个线程 但是没有启动
    Update.Start();才是启动线程
      

  2.   

    少贴了一段:
            private static Thread Update = new Thread(new ThreadStart(IIAPThread.thread1));
            
            private static Thread JudgeNewData = new Thread(new ThreadStart(IIAPThread.thread2));之后:
            public static void startThread(){
                Update.IsBackground = true;
                Update.Start();
            }
      

  3.   

    哪里调用了startThread
      

  4.   

    尝试过在web.config配置handlers节点关键问题,web.config。那么问题就如楼上,你那个地方调用了?解决方法:请找个地方调用他,具体怎么调用我们不好解释,因为如果是iis他得再所谓得“iis预加载”处理
    ps:一般来说application start可以,路由注入那块也行,不过如果是iis承载还是离不开"iis预加载”,iis自己喜欢没事重启应用程序池
      

  5.   

    我在另外一个.cs页面代码里,调用了 IIAPThread.startThread();using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;namespace ChinaCustoms.Application.OMIS
    {
        public class SysStartHandler : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
                IIAPThread.startThread();        }        public bool IsReusable { 
                get {
                    return false;
                } 
            }
        }
    }
      

  6.   

    没调用startThread功能。创建线程也可以用task