using System;
using System.Threading;
using System.Windows.Forms;
namespace Ernie
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
bool flag = false;
private void btnStart_Click(object sender, EventArgs e)
{
if (flag == false)
{
flag = true;
btnStart.Text = "停 止 摇 奖";
Thread th = new Thread(PlayGame);
th.IsBackground = true; // 后台线程
th.Start();
}
else
{
flag = false;
btnStart.Text = "开 始 摇 奖";
}
}
private void PlayGame()
{
Random rd = new Random();
while (flag)
{
lbl01.Text = rd.Next(0, 10).ToString();
lbl02.Text = rd.Next(0, 10).ToS
C#线程幸运数摇奖机小程序
最新推荐文章于 2024-02-09 20:53:38 发布
这篇博客介绍了一个使用C#编程语言实现的线程幸运数摇奖机小程序,结合Thread和Random类,创建了一个在Windows Forms环境下运行的示例应用。
摘要由CSDN通过智能技术生成