代码如下 using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Threading; namespace ConsoleApplication1 { class Program { static Timer s_objTimer; static void Main(string[] args) { Console.WriteLine("启动后台任务...."); TimerCallback call = new TimerCallback(ExecuteTask); s_objTimer = new Timer(call, null, 1000, 300); Console.WriteLine("后台任务启动完毕"); //执行主程序(任务) Console.WriteLine("继续执行主程序......"); Thread.Sleep(5000); Console.WriteLine("主程序运行结束"); Console.WriteLine("按任意键退出"); Console.Read(); } static int s_nCount = 0; static void ExecuteTask(object param) { if (s_nCount == 0) { Con