windows定时任务小注

static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1(args));
        }
    }
        private bool blIsAuto = false;
        public Form1(string[] args)
        {
            InitializeComponent();
            this.Load += new EventHandler(Form1_Load);
            if (args != null && args.Length == 1 && args[0] == "IsAuto")
            {
                blIsAuto = true;
            }
        }


        void Form1_Load(object sender, EventArgs e)
        {
            if (blIsAuto)
            {
                button1.PerformClick();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("一条大河波浪宽");
            if (this.blIsAuto)
            {
                this.Dispose();
                Environment.Exit(0);
            }
        }

其中args提供触发的条件

如图,isAuto就是触发的条件

posted @ 2016-03-10 09:20  洛晨随风  阅读(200)  评论(0编辑  收藏  举报