日期:2014-05-20  浏览次数:20720 次

有关于Timer控件的Start()方法,
#region   圆点和黄点的距离在50范围内,向圆点靠拢
public   void   BugbearClose(float   UserXCoordinate,float   UserYCoordinate)
{
BugbearGather   =   " ";
for(int   i=0;   i <BugbearCoordinateAggregate.Length;i++)
{
string[]   BugbearCoordinate   =   BugbearCoordinateAggregate[i].ToString().Split( ', ');
BugbearXCoordinate   =   Convert.ToInt32(BugbearCoordinate[0].ToString());
BugbearYCoordinate   =   Convert.ToInt32(BugbearCoordinate[1].ToString());

//判断圆点和黄点之间的间距小于等于50,向圆点靠拢
if(Math.Abs(UserXCoordinate   -   BugbearXCoordinate)   <=   50   ||   Math.Abs(UserYCoordinate   -   BugbearYCoordinate)   <=   50)
{
BugbearGather   +=BugbearXCoordinate+ ", "+BugbearYCoordinate+ ", ";
}
if(BugbearGather   !=   " ")
{
BugbearGather   =   BugbearGather.Substring(0,BugbearGather.Length   -   1);
BugbearTimer.Start();
}
}
}
#endregion
现在出现的情况是当程序运行到BugbearTimer.Start();的时候没有去调用BugbearTimer_Tick()这个事件,而又是去执行循环了,不知道要怎么控制当运行Start()的时候,让程序去调用BugbearTimer_Tick()

我的意思:每循环一次,就先判断,符合要求就开始执行BugbearTimer_Tick()
我现在都不知道Start()这个方法是不是控制Tick()事件的?
请各位高手多多帮忙!

------解决方案--------------------
start只是去激活timer..

比如你的timer的时间间隔如果设置的是10s,那么你调用timer.Start()后,还需要等十秒钟才会去执行timer_tick事件...
------解决方案--------------------
樓上正解
------解决方案--------------------
YES
------解决方案--------------------
Tick()事件是Timer每隔一段时间自动触发,也就是说不需要自己写循环。
lz还在问这个问题……
------解决方案--------------------
不太了解楼主的目的,如果只是想当符合条件时执行一下timer_tick事件下的代码的话,那就没有必要写在timer_tick下了,直接写个方法,符合条件时直接调用不就行了?
------解决方案--------------------
你的逻辑我还是没搞清楚,你是想执行timer_tick事件后,让它把数组中的点先画完了,然后再执行下一次循环,还是说timer执行后,继续执行下一次循环?
------解决方案--------------------
虽然还是不太明白lz的思路,不过可以在BugbearTimer.Start()后面加上break跳出循环试试。