国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
C#進(jìn)度條
http://hi.baidu.com/zzh_my/blog/item/701bb61f1a03d703314e156d.html

進(jìn)度條
是一個(gè)軟件人性化考慮之一,他給用戶的感覺就是程序內(nèi)部在不停的動(dòng)作,執(zhí)行到了什么程度,而不是整個(gè)界面僵死,以至于用戶不知道程序在做什么!

  看了好幾個(gè)WinForm程序了,發(fā)現(xiàn)他們對(duì)進(jìn)度條的處理完全失去了進(jìn)度條的作用。他們都是采用Timer來處理,在線程結(jié)束的時(shí)候,直接賦值進(jìn)度條達(dá)到100%。和我以前做WebForm程序的時(shí)候完全不一樣,做WebForm程序的時(shí)候,進(jìn)度條是根據(jù)總體數(shù)據(jù)和每步執(zhí)行后而計(jì)算和更新的。在看了這幾個(gè)WinForm程序后,我在想:是否所有WinForm程序,在進(jìn)度條的處理上都不能保證實(shí)時(shí)進(jìn)度顯示?

  其實(shí)用Timer來處理,不停的更新進(jìn)度條只是程序作者偷懶的方法。當(dāng)然這樣的好處就是可以簡(jiǎn)單化處理進(jìn)度條,代碼量少,不易出錯(cuò),調(diào)試方便。

  還有一種方法,就是可以及時(shí)更新進(jìn)度條的數(shù)據(jù)的。那就是采用事件驅(qū)動(dòng)機(jī)制,在子線程中監(jiān)視復(fù)雜處理過程中的設(shè)定的事件,及時(shí)更新!直接看代碼:
程序代碼using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication1
{
     /// <summary>
     /// Form1 類
     /// </summary>
     public partial class Form1 : Form
     {
         public Form1()
         {
             InitializeComponent();
         }
         private void button1_Click(object sender, EventArgs e)
         {
             //用子線程工作
             new System.Threading.Thread(new System.Threading.ThreadStart(StartDownload)).Start();
         }
         //開始下載
         public void StartDownload()
         {
             Downloader downloader = new Downloader();
             downloader.onDownLoadProgress += new Downloader.dDownloadProgress(downloader_onDownLoadProgress);
             downloader.Start();
         }
         //同步更新UI
         void downloader_onDownLoadProgress(long total, long current)
         {
             if (this.InvokeRequired)
             {
                 this.Invoke(new Downloader.dDownloadProgress(downloader_onDownLoadProgress), new object[] { total, current });
             }
             else
             {
                 this.progressBar1.Maximum = (int)total;
                 this.progressBar1.Value = (int)current;
             }
         }
     }

     /// <summary>
     /// 下載類(您的復(fù)雜處理類)
     /// </summary>
     public class Downloader
     {
         //委托
         public delegate void dDownloadProgress(long total,long current);
         //事件
         public event dDownloadProgress onDownLoadProgress;
         //開始模擬工作
         public void Start()
         {
             for (int i = 0; i < 100; i++)
             {
                 if (onDownLoadProgress != null)
                     onDownLoadProgress(100, i);
                 System.Threading.Thread.Sleep(100);
             }
         }
     }
}=================================ling========================================
delegate object dlExecuteQuery();
private void button1_Click(object sender, EventArgs e)
{
dlExecuteQuery de=new dlExecuteQuery(this.Query());
IAsyncResult ir = de.BeginInvoke(null, null);

Form f=new Form()
f.ShowDialog(this);
Application.DoEvents();
while (!ir.IsCompleted)
{
Application.DoEvents();
}
object obj = de.EndInvoke(ir);
f.Close();
}

private object Query()
{
//長(zhǎng)時(shí)間的操作
}
_______________________________________________________________________________________________________________________________________
private void btnCount_Click(object sender, EventArgs e)
{
label1.Visible
=true;
progressBar.Visible
= true;
progressBar.Minimum
= 0;
progressBar.Maximum
= ds.Tables[""].Rows.Count;
progressBar.BackColor
= Color.Green;
for (int i = 0; i < ds.Tables[""].Rows.Count; i++)

{
progressBar.Value
++;
Application.DoEvents();
this.label1.Text = Convert.ToString(progressBar.Value);
}

}


或者

private void btnCount_Click(object sender, EventArgs e)
{
label1.Visible
=true;
progressBar.Visible
= true;
progressBar.Minimum
= 0;
progressBar.Maximum
= ds.Tables[""].Rows.Count;
progressBar.BackColor
= Color.Green;
for (int i = 0; i < ds.Tables[""].Rows.Count; i++)
{
progressBar.Value
++;
Application.DoEvents();
this.label1.Text = Convert.ToString(progressBar.Value);this.label1.Refresh();
}

}
http://blog.163.com/light_warm/blog/static/3168104200861710226745/





另:


 建立一個(gè)listBox將進(jìn)程名稱遍歷進(jìn)去

this.listBox1.Items.Clear();
Process[] MyProcesses=Process.GetProcesses();
foreach(Process MyProcess in MyProcesses)
{
this.listBox1.Items.Add(MyProcess.ProcessName);
}
this.listBox1.SelectedIndex=0;

 

 選中l(wèi)istBox里面的項(xiàng)后將進(jìn)程詳細(xì)信息顯示在右面的Label中

try
{
string ProcessName=this.listBox1.Text;
this.groupBox1.Text=ProcessName+"進(jìn)程的詳細(xì)信息";
Process[] MyProcess=Process.GetProcessesByName(ProcessName);
this.label1.Text="進(jìn)程影象名:"+MyProcess[0].ProcessName;
this.label2.Text="進(jìn)程ID:"+MyProcess[0].Id;
this.label3.Text="啟動(dòng)線程樹:"+MyProcess[0].Threads.Count.ToString();
this.label4.Text="CPU占用時(shí)間:"+MyProcess[0].TotalProcessorTime.ToString();
this.label5.Text="線程優(yōu)先級(jí):"+MyProcess[0].PriorityClass.ToString();
this.label6.Text="啟動(dòng)時(shí)間:"+MyProcess[0].StartTime.ToLongTimeString();
this.label7.Text="專用內(nèi)存:"+(MyProcess[0].PrivateMemorySize/1024).ToString()+"K";
this.label8.Text="峰值虛擬內(nèi)存:"+(MyProcess[0].PeakVirtualMemorySize/1024).ToString()+"K";
this.label9.Text="峰值分頁內(nèi)存:"+(MyProcess[0].PeakPagedMemorySize/1024).ToString()+"K";
this.label10.Text="分頁系統(tǒng)內(nèi)存:"+(MyProcess[0].PagedSystemMemorySize/1024).ToString()+"K";
this.label11.Text="分頁內(nèi)存:"+(MyProcess[0].PagedMemorySize/1024).ToString()+"K";
this.label12.Text="未分頁系統(tǒng)內(nèi)存:"+(MyProcess[0].NonpagedSystemMemorySize/1024).ToString()+"K";
this.label13.Text="物理內(nèi)存:"+(MyProcess[0].WorkingSet/1024).ToString()+"K";
this.label14.Text="虛擬內(nèi)存:"+(MyProcess[0].VirtualMemorySize/1024).ToString()+"K";
}
catch(Exception Err)
{
MessageBox.Show("沒有此進(jìn)程,無法獲取信息!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
//不處理異常
            }

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
c#訪問EXCEL2003問題
時(shí)間差的計(jì)算
C#多線程隊(duì)列逐個(gè)執(zhí)行
V8.A11ComboBox 控件、ListBox 控件和CheckedListBox 控件
C#窗體——100以內(nèi)加法做題程序
ProgressBar和TrackerBar的使用
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服