BackgroundWorker的简单用法
2015-01-22 16:52
155 查看
微软的官方例子
BackgroudWorker就是一个封装好的异步处理类(就是多线程,广泛用于winform开发中)
例子:
1.界面效果:
一个label,两个button
View Code
BackgroudWorker就是一个封装好的异步处理类(就是多线程,广泛用于winform开发中)
例子:
1.界面效果:
一个label,两个button
namespace BackgroundWorkerTest { partial class Form2 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.btnStart = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // btnStart // this.btnStart.Location = new System.Drawing.Point(42, 165); this.btnStart.Name = "btnStart"; this.btnStart.Size = new System.Drawing.Size(75, 23); this.btnStart.TabIndex = 0; this.btnStart.Text = "开始"; this.btnStart.UseVisualStyleBackColor = true; this.btnStart.Click += new System.EventHandler(this.btnStart_Click); // // btnCancel // this.btnCancel.Location = new System.Drawing.Point(249, 165); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.TabIndex = 1; this.btnCancel.Text = "取消"; this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(61, 47); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(35, 13); this.label1.TabIndex = 2; this.label1.Text = "label1"; // // Form2 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(388, 230); this.Controls.Add(this.label1); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnStart); this.Name = "Form2"; this.Text = "Form2"; this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Button btnStart; private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.Label label1; } }
View Code
相关文章推荐
- asp.net中自定义验证控件的简单用法
- 一个显示日期的简单小程序,主要是学习静态变量的用法
- AjaxPanel自定义控件实现页面无刷新数据交互(做了个示例程序, 效果确实比较Cool, 用法非常简单!
- 常用的JS与XML结合用法 简单示例
- zlib用法简单说明
- 常用的JS与XML结合用法 简单示例
- AjaxPanel自定义控件实现页面无刷新数据交互(做了个示例程序, 效果确实比较Cool, 用法非常简单! )(示例代码下载)
- oracle 数据库一些单行函数的简单用法
- 时间格式化,简单用法
- valarray的一些简单用法
- namespace的简单用法
- 枚举简单用法
- AjaxPanel自定义控件实现页面无刷新数据交互(做了个示例程序, 效果确实比较Cool, 用法非常简单! )(示例代码下载)
- string 简单参数用法
- vi的简单用法
- tar命令的简单用法
- fstream的简单用法
- qmake的简单用法
- 一个演示 CAsyncSocket 用法的极简单的例子.
- DataAdapter.Update() 用法,对简单的字段更新很有用