c#之线程随机
2016-06-13 11:10
489 查看
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 WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Control.CheckForIllegalCrossThreadCalls = false; } bool a; public void playGame() { Random rd = new Random(); while (a) { this.label1.Text = rd.Next(0, 10).ToString(); this.label2.Text = rd.Next(0, 10).ToString(); this.label3.Text = rd.Next(0, 10).ToString(); } } private void button1_Click(object sender, EventArgs e) { if (!a) { a=true; this.button1.Text = "暂停"; Thread th = new Thread(playGame); th.IsBackground = true; th.Start(); } else { this.button1.Text = "开始"; a = false; } } } }
相关文章推荐
- C#: 统计method的执行时间
- C#中override和overload的区别
- 一个简单的金额平均分配函数(C#版)
- C#.net编程创建Access文件和Excel文件的方法详解
- Web Services and C# Enums
- C#之参数线程
- VS2010 常用快捷键
- C#使用二分查找法判断指定字符的方法
- C#项目中发生PInvokeStackImbalance异常,堆栈不对称异常
- 逐步讲解快速排序算法及C#版的实现示例
- C#中的Action<>和Func<>
- C#简单判断字符编码的方法
- C#判断字符编码的方法总结(六种方法)
- C#实现的一款比较美观的验证码完整实例
- 基于Emgu CV的图像处理 第一章 环境配置
- C#实现数独计算器
- C#做的接口
- C#使用IrisSkin2.dll美化WinForm程序界面
- c# 软件更新实例
- c# 软件更新实例