怎样让程序同时运行多个任务....用多线程还是多进程吗?!
我想做一个这样的程序:
有3个定时器...分别定时做不同的任务...而且互相不干扰...
定时器1: 每个1个小时提醒"应该休息了"
定时器2:每个2小时去放一首音乐
定时器3:每个3小时去....做另外一个任务...
这样...也不一定是一个定时器.可能是多个....
类似的程序应该是什么思路...用多线程或者多进程吗?!
能给个类似的程序代码或者思路吗?!

解决方案 »

  1.   

    多线程,很好,System.Threading.Timer就是一个多线程的时钟,可以试试
      

  2.   

    new Thread(delegate(){//你要干的某个事~~~}).Start();
      

  3.   

    AutoResetEvent AutoReset = new AutoResetEvent(false);
        Timer timer = new Timer(new TimerCallback(MyUpdateService1.MyAsyncOperation), AutoReset, 0, 0x493e0);
        AutoReset.WaitOne(0x186a0, false);
    private static void MyAsyncOperation(object state)
    {
        try
        {
            Monitor.Enter(typeof(MyUpdateService1));
            MyImpClass.MovLast();
        }
        finally
        {
            Monitor.Exit(typeof(MyUpdateService1));
        }
        ((AutoResetEvent) state).Set();