人生是一场不能存盘的RPG,我只能尽量多搞几个Screenshot

June 16, 2006

不断调用System.Timers.Timer的Stop()和Start方法,会导致程序占用的内存和线程数骤增.

Filed under: .NET, My Questions

不断调用System.Timers.Timer的Stop()和Start方法,会导致程序占用的内存和线程数骤增.

System.Timers.Timer _tmr;

private void button1_Click(object sender, System.EventArgs e)
{
_tmr = new System.Timers.Timer();
_tmr.Interval = 10000000;
_tmr.Start();

while(true)
{
_tmr.Stop();
//Thread.Sleep(300); 如果使用了sleep,情况会大幅缓和,但线程数会增加.
_tmr.Start();
}

为什么?

Comments »

The URI to TrackBack this entry is: http://recordsome.blogsome.com/2006/06/16/p111/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.






















Get free blog up and running in minutes with Blogsome
Theme designed by Hadley Wickham