目录
一 设计原型
二 后台源码
一 设计原型
二 后台源码
namespace 跑马灯
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Color[] colors = { Color.Red, Color.Green, Color.Yellow };
Task.Run(() =>
{
while (true)
{
Thread.Sleep(1000);
this.BeginInvoke(new Action(() => { uiLight1.OnColor = colors[new Random().Next(0, 3)]; }));
Thread.Sleep(2000);
this.BeginInvoke(new Action(() => { uiLight2.OnColor = colors[new Random().Next(0, 3)]; }));
Thread.Sleep(3000);
this.BeginInvoke(new Action(() => { uiLight3.OnColor = colors[new Random().Next(0, 3)]; }));
}
});
}
}
}