只贴关键代码:
1、父窗体关键代码
 
 
        private void doAt1AM(object state)
        {//要执行的任务,直接button调用即可
            //执行功能...的任务
           
            spring_Form spr_Form = new spring_Form();
            spr_Form.Txt = "陈先生" + ";到1号窗口取药";
         
            spr_Form.ShowDialog();//模式窗体弹出,当前窗体拥有对子窗体的控制权,子窗体未关闭前不能对父窗体操作
              
             非模式窗体   //qform.Show();
            模式窗体  //qform.ShowDialog();
           
            setTaskAtFixedTime();
        }
        private void setTaskAtFixedTime()
        {//定义自动循环执行方法
            DateTime now = DateTime.Now;
            DateTime oneOClock =                 
           DateTime.Now.AddMilliseconds(Convert.ToDouble(5000));//ss自动执行 添加毫秒
            if (now > oneOClock)
            {
                oneOClock = DateTime.Now.AddMilliseconds(Convert.ToDouble(5000));//5s自动执行
            }
            int msUntilFour = (int)((oneOClock - now).TotalMilliseconds);
            var t = new System.Threading.Timer(doAt1AM);
            t.Change(msUntilFour, Timeout.Infinite);
        }2、子窗体关键代码,子窗体使timer控件,运行3s后自动关闭当前窗体
        string txtname;//定义接收传参的变量
   
        public string Txt
        {//定义方法,调用方法传参
            set { txtname = value; }
        }
          private void spring_Form_Load(object sender, EventArgs e)
        {
            // 设置窗体置顶
          
            string[] item = txtname.Split(';');//通过=号截取字符
             label2.Text = item[0];//获取叫号患者
            label3.Text = item[1];
          
            this.FormBorderStyle = FormBorderStyle.None;    //设置窗体为无边框样式
           
            this.TopMost = true;//置顶当前窗体
            Screen[] sc = Screen.AllScreens;
            if (sc.Count() == 2)
            {
                //我的显示器sc[0]是第二块屏幕,如第二块屏幕在位置2,则此处为1
                this.Left = sc[1].Bounds.Left + (sc[0].Bounds.Width - this.Width) / 2;
                this.Top = (sc[1].Bounds.Height - this.Height) / 2;
            }
            //设置一个定时器3s后自动隐藏的功能
            timer1.Interval = 3000;
            timer1.Start();
        }
         private void timer1_Tick_1(object sender, EventArgs e)
        {
           //需要在timer的触发事件里选择此方法
           
            this.Close();//关闭当前窗体
           
        }
子窗体效果展示




















