日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > C# >内容正文

C#

c#滚动条创建实例,多线程

發(fā)布時(shí)間:2023/12/18 C# 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c#滚动条创建实例,多线程 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.滾動(dòng)條

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

namespace WindowsFormsApplication1
{
? ? public partial class MyProgressBar : Form
? ? {
? ? ? ? public MyProgressBar()
? ? ? ? {
? ? ? ? ? ? InitializeComponent();
? ? ? ? ? ? Initial();
? ? ? ? }
? ? ? ? public static int maxValue = 0;
? ? ? ? public static int minValue = 0;

? ? ? ? public void Initial()
? ? ? ? {

? ? ? ? ? ? this.progressBar1.Maximum = 100;
? ? ? ? ? ? this.progressBar1.Minimum = 0;

? ? ? ? ? ? maxValue = 100;
? ? ? ? ? ? minValue = 0;

? ? ? ? }


? ? ? ? //public delegate void UpdateValue(int value);
? ? ? ? public bool UpdateValue(int nValue)
? ? ? ? {
? ? ? ? ? ? while (!this.IsHandleCreated)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? //MessageBox.Show("等待窗體句柄創(chuàng)建");
? ? ? ? ? ? };
? ? ? ? ? ? //try
? ? ? ? ? ? //{
? ? ? ? ? ? ? ? this.Invoke(new Action(() =>
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? //if (this.Handle == null) return ;
? ? ? ? ? ? ? ? ? ? if (nValue > 0)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? this.label1.Text = nValue.ToString()+"%";
? ? ? ? ? ? ? ? ? ? ? ? if ( nValue < progressBar1.Maximum)
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? progressBar1.Value =nValue;

? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? progressBar1.Value = progressBar1.Maximum;
? ? ? ? ? ? ? ? ? ? ? ? ? ? this.Close();

? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? }));
? ? ? ? ? ? ? ? return true;
? ? ? ? ? ? //}
? ? ? ? ? ? //catch(Exception ee)
? ? ? ? ? ? //{
? ? ? ? ? ? ? ? //MessageBox.Show(ee.ToString());
? ? ? ? ? ? ? ? return true;
? ? ? ? ? ? //}
? ? ? ? }

? ? ? ??

? ? }
}
2.主窗體調(diào)用

?public delegate bool UpdateProgressValue(int value);
? ? ? ? public event UpdateProgressValue UpdateProgressEvent;
? ? ? ? public void CreatedataLineFile(string folderPath)
? ? ? ? {

? ? ? ? ? ? //創(chuàng)建進(jìn)度條
? ? ? ? ? ? Thread th = new Thread(() =>
? ? ? ? ? ? {

? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? MyProgressBar pb = new MyProgressBar();
? ? ? ? ? ? ? ? pb.StartPosition = FormStartPosition.CenterScreen;
? ? ? ? ? ? ? ? UpdateProgressEvent += pb.UpdateValue;
? ? ? ? ? ? ? ? pb.ShowDialog();
? ? ? ? ? ? });
? ? ? ? ? ? th.Start();

? ? ? ? ? ? while (UpdateProgressEvent == null) ;
? ? ? ? ? ? for (int i = 0; i < 1000;i++ )
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Thread.Sleep(10);
? ? ? ? ? ? ? ? UpdateProgressEvent(Convert.ToInt32(i * 1.0 / 1000 * (MyProgressBar.maxValue - MyProgressBar.minValue)+MyProgressBar.minValue));
? ? ? ? ? ? }
? ? ? ? ? ? ? ?
? ? ? ? ? ? return;

}

總結(jié)

以上是生活随笔為你收集整理的c#滚动条创建实例,多线程的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。