110,534
社区成员
发帖
与我相关
我的任务
分享
private void Form1_Load(object sender, EventArgs e)
{
timer1.Interval = 5000;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
System.Threading.Thread thread = new System.Threading.Thread(ShowForm2);
thread.Start();
}
private void ShowForm2()
{
//根据一系列代码查询条件,判断是否要执行以下弹窗
Form2 form = new Form2();//将窗口Messages 实例化
Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - form.Width, Screen.PrimaryScreen.WorkingArea.Height);
form.PointToClient(p);
form.Location = p;
form.Show();
for (int i = 0; i < form.Height; i++)
{
form.Location = new Point(p.X, p.Y - i);
System.Threading.Thread.Sleep(1);//消息框弹出速度,数值越大越慢
}
}
private void ShowForm2()
{
//根据一系列代码查询条件,判断是否要执行以下弹窗
Application.Run(new Form2());
//Form2 form = new Form2();//将窗口Messages 实例化
//Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - form.Width, Screen.PrimaryScreen.WorkingArea.Height);
//form.PointToClient(p);
//form.Location = p;
//form.Show();
//for (int i = 0; i < form.Height; i++)
//{
// form.Location = new Point(p.X, p.Y - i);
// System.Threading.Thread.Sleep(1);//消息框弹出速度,数值越大越慢
//}
}
private void MainForm_Load(object sender, EventArgs e)
{
timer1.Start(); //用于读库判断是否要显示新的窗体
timer2.Start(); //用于显示新的窗体
}
bool blnShowForm2 = false; //在timer1中读库后修改该变量,在timer2中读取该变量
private void timer1_Tick(object sender, EventArgs e)
{
//后台运行timer1
System.Threading.ThreadStart start = new System.Threading.ThreadStart(this.CheckToShow);
new System.Threading.Thread(start).Start();
}
private void CheckToShow()
{
//模拟查库判断逻辑
int a = 5;
int b = 3;
if ( a > b )
{
blnShowForm2 = true;
}
else
{
blnShowForm2 = false;
}
}
private void timer2_Tick(object sender, EventArgs e)
{
if (blnShowForm2)
{
ShowForm2();
}
}
private void ShowForm2()
{
//根据timer1的判断结果决定是否执行以下步骤
if (!blnShowForm2)
{
return;
}
Form2 form = new Form2();//将窗口Messages 实例化
Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - form.Width, Screen.PrimaryScreen.WorkingArea.Height);
form.PointToClient(p);
form.Location = p;
form.Show();
System.Threading.ThreadPool.QueueUserWorkItem(delegate
{
for (int i = 0; i < form.Height; i++)
{
this.Invoke((MethodInvoker)delegate
{
form.Location = new Point(p.X, p.Y - i);
});
System.Threading.Thread.Sleep(1);//消息框弹出速度,数值越大越慢
}
});
}
private void ShowForm2()
{
//根据一系列代码查询条件,判断是否要执行以下弹窗
this.Invoke(new EventHandler(delegate
{
Form2 form = new Form2();//将窗口Messages 实例化
Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - form.Width, Screen.PrimaryScreen.WorkingArea.Height);
form.PointToClient(p);
form.Location = p;
form.Show();
for (int i = 0; i < form.Height; i++)
{
form.Location = new Point(p.X, p.Y - i);
System.Threading.Thread.Sleep(5);//消息框弹出速度,数值越大越慢
}
}));
}