感觉大家都很热情,真心感谢大家!一牛人建议可以说一下具体要实现的功能这样才好解决问题。于是又开此贴说明一下
具体的功能:在界面加2个textbox,一个button。按一次button为仿真状态,textbox1:每隔1s显示一个数据(1,2,4,5,8,9),每6s循环一次。textbox2:每隔1s显示一个数据(2,3,4,6,8,11),每6s循环一次。textbox1和textbox2同时更新数据。再按一次button,textbox1和textbox2显示“接收数据”!
再次谢谢大家!c# 数据 模拟

解决方案 »

  1.   

    再按一次button,其实我是想接收wifi发过来的数据,只不过为了简单才写的显示接收数据。另外程序在执行数据仿真的时候,我的程序另一部分也在实现其他功能,数据仿真不能影响到其他进程的使用。
      

  2.   


    //界面控件textBox1,textBox2,button1,timer1,timer2
     public partial class Form1 : Form
        {
            public bool flag = false;
            public int a = 0;
            public int b = 0;
            public static string[] txta = { "1", "2", "4", "5", "8", "9" };
            public static string[] txtb = { "2", "3", "4", "6", "8", "11" };
            public Form1()
            {
                InitializeComponent();
            }        private void timer1_Tick(object sender, EventArgs e)
            {
                textBox1.Text = txta[a].ToString();
                a++;
                a = a % 6;
            }        private void timer2_Tick(object sender, EventArgs e)
            {
                textBox2.Text = txtb[b].ToString();
                b++;
                b=b%6;
            }        private void Form1_Load(object sender, EventArgs e)
            {
                timer1.Interval = 1000;
                timer2.Interval = 1000;
            }        private void button1_Click(object sender, EventArgs e)
            {
                flag = !flag;
                if (flag)
                {
                    timer1.Start();
                    timer2.Start();
                }
                else
                {
                    timer1.Stop();
                    timer2.Stop();
                    textBox1.Text = "接收数据";
                    textBox2.Text = "接收数据";
                }
            }    }
      

  3.   

    thank you!你的指导对我很有帮助,谢谢啦!祝愿你的编程水平越来越厉害,哈哈哈