コード例 #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            duobo db1 = new duobo()
            {
                ID = 1
            };
            duobo db2 = new duobo()
            {
                ID = 2
            };
            duobo db3 = new duobo()
            {
                ID = 3
            };
            Action action1 = new Action(db1.dohomework);
            Action action2 = new Action(db2.dohomework);
            Action action3 = new Action(db3.dohomework);

            //action1 += action2;
            //action1 += action3;

            //action1();


            //异步调用
            action1.BeginInvoke(null, null);
            action3.BeginInvoke(null, null);
            action2.BeginInvoke(null, null);
        }
コード例 #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            duobo db1 = new duobo()
            {
                ID = 1
            };
            duobo db2 = new duobo()
            {
                ID = 2
            };
            duobo db3 = new duobo()
            {
                ID = 3
            };
            Thread thread1 = new Thread(new ThreadStart(db1.dohomework));
            Thread thread2 = new Thread(new ThreadStart(db2.dohomework));
            Thread thread3 = new Thread(new ThreadStart(db3.dohomework));

            thread1.Start();
            thread2.Start();
            thread3.Start();
        }
コード例 #3
0
        private void button6_Click(object sender, EventArgs e)
        {
            duobo db1 = new duobo()
            {
                ID = 1
            };
            duobo db2 = new duobo()
            {
                ID = 2
            };
            duobo db3 = new duobo()
            {
                ID = 3
            };

            Task task1 = new Task(new Action(db1.dohomework));
            Task task2 = new Task(new Action(db2.dohomework));
            Task task3 = new Task(new Action(db3.dohomework));

            task1.Start();
            task2.Start();
            task3.Start();
        }