zoukankan      html  css  js  c++  java
  • C# 线程

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Threading;

    namespace WindowsFormsApplication2
    {
        public partial class Form2 : Form
        {
            //Test ts = new Test(lbl);
            public Form2()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                TestPrint();
            }


            private string Message = "";
            private Thread thread;
            private DateTime d;
            private int pageIndex = 1;

            //public Test(Label l)
            
    //{

            
    //}

            public void TestPrint()
            {
                thread = new Thread(TestPrintStart);
                thread.Start();
            }

            public void TestPrintStart()
            {
                d = DateTime.Now;
                Message += "New Printing Start\r\n";
                thread.Join(3000);
                TestPageStart();
            }

            public void TestPageStart()
            {
                Message += string.Format("Wait {0} Seconds\r\n", ((TimeSpan)(DateTime.Now - d)).TotalSeconds);
                TestPageEnd();
            }

            public void TestPageEnd()
            {
                Message += string.Format("Printing Page {0} \r\n", pageIndex);
                if (pageIndex == 5)
                {
                    TestPrintEnd();
                }
                else
                {
                    pageIndex++;
                    d = DateTime.Now;
                    thread.Join(3000);
                    TestPageStart();
                }
            }

            public void TestPrintEnd()
            {
                Message += string.Format("Printing End");
                lbl.Text = Message.ToString();
            }
        }
    }
  • 相关阅读:
    ssh-copy-id 的使用方法
    如何保证 docker daemon重启,但容器不重启
    vim设置golang语法高亮 (Centos)
    Error response from daemon: Error running DeviceCreate (createSnapDevice) dm_task_run failed
    Please supply the message using either -m or -F option.
    sudo: Sorry, you must have a tty to run sudo Error on a Linux and Unix
    vim plugins (vim 插件) 工具集
    OmniGraffle v6 注册码
    test
    Collections.addAll 为什么比collection.addall 快(转)
  • 原文地址:https://www.cnblogs.com/Snowfun/p/2865930.html
Copyright © 2011-2022 走看看