标题:计时器问题
只看楼主
longdunxiong
Rank: 2
等 级:论坛游民
帖 子:8
专家分:20
注 册:2012-2-21
 问题点数:0 回复次数:6 
计时器问题
C# 中的计时器 怎么让一个计时器先执行完了之后,再让第二个执行
搜索更多相关主题的帖子: 计时器 
2012-02-23 09:59
红色警戒
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:19
帖 子:444
专家分:2967
注 册:2005-11-20
得分:0 
不同时启动定时器:在第一个定时器中启动第二个定时器;或同时启动定时器,设置一个变量,第二个定时器判断变量的值执行里面的代码,第一个定时器更改变量;

2012-02-23 10:07
longdunxiong
Rank: 2
等 级:论坛游民
帖 子:8
专家分:20
注 册:2012-2-21
得分:0 
谢谢
2012-02-23 19:40
_迷_
Rank: 2
等 级:论坛游民
帖 子:16
专家分:32
注 册:2012-2-17
得分:0 
在第一个计时器里启动第二个计时器就可以了啊
2012-02-24 19:05
longdunxiong
Rank: 2
等 级:论坛游民
帖 子:8
专家分:20
注 册:2012-2-21
得分:0 
嗯 ,  呵呵   我已经做好了
2012-03-03 17:50
A_Llin
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2012-3-4
得分:0 
把你编的代码发来借鉴哈
2012-03-05 21:48
longdunxiong
Rank: 2
等 级:论坛游民
帖 子:8
专家分:20
注 册:2012-2-21
得分:0 
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace T6.红绿灯
{
    public partial class frmRedGreen2 : Form
    {
        int red, yello, green, count = 0;

        public frmRedGreen2()
        {
            InitializeComponent();
        }

        private void frmRedGreen2_Load(object sender, EventArgs e)
        {
            pbImage.Image=imageL.Images[0];
        }

        private void button1_Click(object sender, EventArgs e)
        {
            red=Convert.ToInt32(txtRed.Text.ToString());
            
            yello = Convert.ToInt32(txtYello.Text.ToString());

            green = Convert.ToInt32(txtGreen.Text.ToString());
        }
        private void btnStart_Click(object sender, EventArgs e)
        {
            Time.Enabled = true;
            count = red;
            
        }
        private void Time_Tick(object sender, EventArgs e)
        {
            pbImage.Image = imageL.Images[1];
            lblTime.Text = count.ToString();
            count--;
            if (count==0)
            {
                Time1.Enabled = true;
                Time.Enabled = false;
                count = yello;
            }
        }

        private void Time1_Tick(object sender, EventArgs e)
        {
            pbImage.Image = imageL.Images[2];
            lblTime.Text = count.ToString();
            count--;
            if (count == 0)
            {
                Time2.Enabled = true;
                Time1.Enabled = false;
                count = green;
            }
        }

        private void Time2_Tick(object sender, EventArgs e)
        {
            pbImage.Image=imageL.Images[3];
            lblTime.Text = count.ToString();
            count--;
            if (count == 0)
            {
                Time.Enabled = true;
                Time2.Enabled = false;
                count = red;
            }
        }

        private void btbStop_Click(object sender, EventArgs e)
        {
            Time.Enabled = false;
            Time1.Enabled = false;
            Time2.Enabled = false;
        }

      


    }
}
2012-03-06 20:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-361430-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.058801 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved