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 ProgressBar
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    //更新进度列表
    private delegate void SetPos(int ipos);

    private void SetTextMessage(int ipos)
    {
    if (this.InvokeRequired)
    {
    SetPos setpos = new SetPos(SetTextMessage);
    this.Invoke(setpos, new object[] { ipos });
    }
    else
    {
    this.label1.Text = ipos.ToString() + "/100";
    this.progressBar1.Value = Convert.ToInt32(ipos);
    }
    }

    private void button1_Click(object sender, EventArgs e)
    {
    Thread fThread = new Thread(new ThreadStart(SleepT));//开辟一个新的线程
    fThread.Start();

    }

    private void SleepT()
    {
    for (int i = 0; i < 500; i++)
    {
    System.Threading.Thread.Sleep(100);//没什么意思,单纯的执行延时
    SetTextMessage(100 * i / 500);
    }
    }
    }
    }

  • 相关阅读:
    opengl中对glOrtho()函数的理解
    cocos2D-x demo 的源码分析 #define ..##.. 的妙用.
    js练习图片轮播
    js 表单操作form
    JS DOM
    java Map
    html--form表单
    java反射应用
    JDBC的使用-----Statement
    sql 查询语句的练习2
  • 原文地址:https://www.cnblogs.com/Devil1314/p/3246045.html
Copyright © 2011-2022 走看看