开发者

system timers timer dispose problem

I am developing one chat application on c#,and on that we use system.timer.timer for frequently getting data for new request and zone request also.

all the thing is running fine but when ever i sign out from application then this system timer is still running on background and generate error.so what i do for dispose all system ti开发者_开发问答mer when signout.

Please help me for this.

thanks in advance


You need to call Stop() when you sign out.


I immagine you tried already Stop() and Close(). If so, solution could be: during the closing of you applicaiton to make Sleep() for a couple of seconds main thread to let to timer's thread release resources allocated before.

There could be also a bug in application, which blocks timer's thread for some reason, but it's difficult to say to me, you should check it by yourself.

Hope this helps.

Regards.


I'd say it's something else that's blocking your program. System.Timers.Timer creates a thread in the threadpool, meaning its a background thread, meaning it shuts down when your main thread does.

I think it's in the requests you do in your timer_elapsed function, which runs on your main thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜