Beispiel #1
0
        private void TextBox1(object textntime)
        {
            TextnTime time = (TextnTime)textntime;

            while (i == true)
            {
                Action <string> ac = new Action <string>(SetValue);
                this.Invoke(ac, time.Text);
                Thread.Sleep(time.Time);
            }
        }
Beispiel #2
0
        public void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            threadList    = new List <Thread>();
            List <string> listTextBox = new List <string>();

            listTextBox.Add(textBox2.Text);
            listTextBox.Add(textBox3.Text);
            listTextBox.Add(textBox4.Text);
            int x = 1;

            i = true;

            foreach (var item in listTextBox)
            {
                Random rd  = new Random();
                int    rng = rd.Next(500, 1000);


                TextnTime tt = new TextnTime();
                tt.Text = item;
                tt.Time = x * rng;
                x++;

                ParameterizedThreadStart start = new ParameterizedThreadStart(TextBox1);
                Thread thread = new Thread(start);
                threadList.Add(thread);
                thread.Start(tt);
            }

            //ThreadStart a = new ThreadStart(TextBox1);
            //thread_1 = new Thread(a);
            //ThreadStart b = new ThreadStart(TextBox2);
            //thread_2 = new Thread(b);
            //ThreadStart c = new ThreadStart(TextBox3);
            //thread_3 = new Thread(c);
            //  thread_1.Start();
            //thread_2.Start();
            //thread_3.Start();
        }