111,118
社区成员
发帖
与我相关
我的任务
分享ClassStartThread startThread = new ClassStartThread( this.label1);
Thread st = new Thread(new ThreadStart(startThread.StartThread));
tUdpThread.IsBackground = true;
tUdpThread.Start();
[code=C#]
class ClassStartThreadnamespace WindowsApplication5
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(58, 53);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(71, 29);
this.label1.TabIndex = 0;
this.label1.Text = "我闪";
//
// timer1
//
this.timer1.Interval = 200;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// timer2
//
this.timer2.Interval = 200;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// button1
//
this.button1.Location = new System.Drawing.Point(270, 78);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(386, 606);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.Button button1;
}
}using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication5
{
public partial class Form1 : Form
{
private int nN = 0, nCount = 0;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Visible = true;
timer1.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
timer2.Enabled = true;
}
private void timer2_Tick(object sender, EventArgs e)
{
if (nCount >= 2 * nN - 1)
{
nCount = 0;
nN++;
label1.Visible = false;
timer1.Enabled = true;
}
nCount++;
}
}
}