1.vb.net 多次滚动抽奖的奖源奖源程序代码
vb.net 多次滚动抽奖的程序代码
我用多线程写的,你可以参考下。码抽性格源码类型系统界面图如下:(注:重置功能为清除已经中奖号码,代码阿里pdf源码回归1-都可以中奖状态。奖源奖源raft架构源码)
代码:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
System.Threading.Thread g_Thread = null;
List<int> g_list = new List<int>();
int g_Num = 0;
delegate void g_delegate();
/// <summary>
/// 开始
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender,码抽源码erp物流 EventArgs e)
{
if(g_list.Count==)
{
MessageBox.Show("所有数字已使用,请重置!代码css下载源码");
return;
}
button3.Enabled = true;
Random r = new Random();
g_delegate dele= ChangeTxt;
g_Thread = new System.Threading.Thread(() =>
{
while(this.IsDisposed==false)
{
g_Num = r.Next(1,奖源奖源 );
if(g_list.Contains(g_Num))
{
g_Num = 1;
}
while(g_list.Contains(g_Num))
{
g_Num++;
}
this.Invoke(dele);
System.Threading.Thread.Sleep();
}
});
g_Thread.Start();
}
void ChangeTxt()
{
label2.Text = g_Num.ToString();
}
/// <summary>
/// 停止
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
//if(g_Thread.ThreadState==System.Threading.ThreadState.Running)
{
g_Thread.Abort();
g_list.Add(Convert.ToInt(label2.Text));
}
button3.Enabled = false;
}
/// <summary>
/// 重置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
g_list.Clear();
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
System.Environment.Exit(0);
}
}