WINDOWS自己带计划任务.. 
SQL的作业... 
或则其他第三方的..不都可以吗?

解决方案 »

  1.   

    据说可以开线程。。我做了个东西,哎,我菜,也只是用windows的计划任务,这样不好 的 。。
      

  2.   

    除了自带的作业之类  我也想过这
    个人建议  
    用ajax和timer控件  可以试试
    不过就是太大
    你可以试试
    我没事过
      

  3.   

    1.如果你的网站是天天有人使用的
    那么你可以在数据库中建个表用来记录发送邮件的时间以及下一次发送的时间
    程序判断是否符合发送时间,是则发送并记录下一次发送时间2.如果你的网站不能保证天天有人访问那么做好的选择还是windows服务
      

  4.   

    用WINDOWS自动计划来访问你的程序比较合适。。方便。
      

  5.   

    在sql 中建一个表,记录上次发送的时间,首页或登录后(根据情况而定,不能太频繁但也要保证此页面每天至少有一次访问量)用当前数据库时间与此表时间做比较。如果相差一个月则发送邮件,更改此表时间。windows 服务不可取,timer事件也不可取。sql server 中有发送邮件的功能,可以考虑用sql 事务的方式sql server 发送邮件。
      

  6.   

    最好是自己写个软件  或者是window service  你想在网站中实现的话  可以在Global.asax  中Application_Start 中实现
      

  7.   

     private static System.Threading.Timer timer;
        private const int interval = 1000 * 60 * 20;//时间间隔
     void Application_Start(object sender, EventArgs e) 
        {
    // 在应用程序启动时运行的代码
            if (timer == null)
                timer = new System.Threading.Timer(new System.Threading.TimerCallback(ScheduledWorkCallback),
                    sender, 0, interval);
          }
      

  8.   

    WEB中也可以做任务的,可以实现像数据库作业一样,定时,按条件执行
      

  9.   

    楼主用Winform做个小程序来自动执行
      

  10.   

    如果服务器是自己的,那就随便搞了,写个winform的小程序实现比较简便稳定。
    不是自己控制的服务器,那就在网站程序里实现,
      

  11.   

    namespace T
    {
        public delegate void MinuteTickEventHandler(object p_Sender, DateTime p_Time);
        public delegate void HourTickEventHandler(object p_Sender, DateTime p_Time);
        internal class Timer
        {
            private bool m_Stop = false;
            private DateTime m_PrevHour;
            public bool Running
            {
                get
                {
                    return !m_Stop;
                }
            }
            public event MinuteTickEventHandler MinuteTick;
            public event HourTickEventHandler HourTick;
            public void Run()
            {
                int scount = 0;
                while (!m_Stop)
                {
                    try
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(1));
                        scount++;
                        if (scount >= 86400)//你一个月执行一次就是scount >= 30*24*3600秒
                        {
                            scount = 0;
                            P.PP();//在此调用
                            ExecuteTrigger();
                        }                }
                    catch { }
                }
            }        public void Start()
            {
                m_Stop = false;
                m_PrevHour = DateTime.Now;
            }        public void Stop()
            {
                m_Stop = true;
            }
            private void ExecuteTrigger()
            {
                OnMinuteTick(DateTime.Now);            DateTime now = DateTime.Now;
                if (m_PrevHour.Hour < now.Hour)
                {
                    m_PrevHour = now;
                    OnHourTick(now);
                }
            }
            private void OnMinuteTick(DateTime p_Now)
            {
                if (MinuteTick != null)
                    MinuteTick(this, p_Now);
            }
            private void OnHourTick(DateTime p_Now)
            {
                if (HourTick != null)
                    HourTick(this, p_Now);
            }
        }
        internal class Scheduler
        {
            private Timer m_Timer;
            public void Start()
            {
                if (m_Timer != null)
                {
                    if (!m_Timer.Running)
                    {
                        m_Timer.Start();
                        Thread thread = new Thread(new ThreadStart(m_Timer.Start));
                        thread.Start();
                    }
                }
                else
                {
                    m_Timer = new Timer();
                    m_Timer.Start();
                    Thread thread = new Thread(new ThreadStart(m_Timer.Run));
                    thread.Start();
                }
            }        public void Stop()
            {
                if (m_Timer != null)
                    m_Timer.Stop();
            }
        }
        
        class P 
        {
            private static Scheduler m_Scheduler;
            public static void Start(string s)
            {
                m_Scheduler = new Scheduler();
                m_Scheduler.Start();
            }
            public static void Stop(string s)
            {
                m_Scheduler.Stop();
            }
            public static void PP()
            {
                //实际工作
            }
        }
    }
      

  12.   

    。。!还有sleep一个线程1个月的..
    有1万个用户您就在服务器上死睡1w个线程1个月啊
    途中服务器要是重启了一次,这些个用户就更惨了
    有朋友说用global,我没觉得global中有合适的事件去做这个工作服务器是自己的,写个控制台程序每天运行一次,一刻钟写完,稳定可靠
    服务器不是自己的,写个页面提供发邮件功能,管理员每天去点一下;没空点就写个外挂,每天自动登录网站点一下
    以后用户需求改了,也不用改你的网站再发布
      

  13.   

    关注,我现在时在Global中用Timer,已经运行了一周多时间了,可是又一次没有执行,感觉稳定性有问题啊 关注楼主的解决办法!
      

  14.   

    在gloal.asax中设定一个检查函数,每天检查一次,如果满足一个月就执行。
      

  15.   

    用service吧,我也是要做一个类似于楼主一样需求的功能。。 最后选择了windows service。。 b/s里面做计划任务是要保证至少有人访问web吧??