再发关于线程调用timer的问题 ,求高人指点!!!

ztqye 2005-12-05 12:29:00
我要实现的是显示一个类似qq好友上线消息提示的东西
下面是调用的代码:
NoteMsgForm newnote=new NoteMsgForm();
newnote.label1.Text="朋友你好!";
///////////////////////////////////////////////////////
///a方案
// Thread new1=new Thread(new ThreadStart(newnote._ScrollShow));
// new1.Start();
//a方案结束
///////////////////////////////////////////////////////
///b方案
newnote._ScrollShow();
///b方案结束
////////////////////////////////////////////////////////////
a和b有什么区别?怎么b能行,a不行呢?

NoteMsgForm 类内容如下:
private void NoteMsgForm_Load(object sender, System.EventArgs e)
{
try
{
Screen[] screens = Screen.AllScreens;
Screen screen = screens[0];//获取屏幕变量
this.Location = new Point(screen.WorkingArea.Width - widthMax - 20, screen.WorkingArea.Height - 34);//WorkingArea为Windows桌面的工作区
this.timer2.Interval = StayTime;
}
catch
MessageBox.Show("error");}

}
private void ScrollUp()
{

if(Height < heightMax)
{
this.Height += 3;
this.Location = new Point(this.Location.X, this.Location.Y - 3);
}
else
{
this.timer1.Enabled = false;
this.timer2.Enabled = true;
}
}
}

private void ScrollDown()
{

if(Height > 3)
{
this.Height -= 3;
this.Location = new Point(this.Location.X, this.Location.Y + 3);
}
else
{
this.timer3.Enabled = false;
this.Close();
}
}
public void _ScrollShow()
{
this.Width = widthMax;
this.Height = 0;
this.Show();
this.timer1.Enabled = true;
}

private void timer1_Tick(object sender, System.EventArgs e)
{
ScrollUp();
}

private void timer2_Tick(object sender, System.EventArgs e)
{
timer2.Enabled = false;
timer3.Enabled = true;
}

private void timer3_Tick(object sender, System.EventArgs e)
{
ScrollDown();
}

...全文
101 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧