110,571
社区成员
发帖
与我相关
我的任务
分享
//创建窗体
Thread t = new Thread(new ThreadStart(() =>
{
Form2 frm2 = new Form2();
this.BeginInvoke(new Action(()=>{frm2.Show();}));
}));
t.Start();
//测试窗体
public partial class Form2 : Form
{
System.Timers.Timer timer = new System.Timers.Timer();
delegate void DelSetOpacity();
public Form2()
{
InitializeComponent();
timer.Interval = 20;
timer.Elapsed += timer_Elapsed;
}
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
this.BeginInvoke(new Action(() =>
{
if (this.Opacity < 0.99)
this.Opacity += 0.01;
}));
}
private void Form2_Load(object sender, EventArgs e)
{
DelSetOpacity del1 = new DelSetOpacity(SetOpacity);
del1.BeginInvoke(new AsyncCallback(CallBack), null);
//timer.Start();
}
private void CallBack(IAsyncResult ar)
{
}
private void SetOpacity()
{
while (true)
{
Thread.Sleep(20);
this.BeginInvoke(new Action(() =>
{
if (this.Opacity < 0.99)
this.Opacity += 0.01;
}));
}
}
}