mayur Rathod
mayur Rathod

Reputation: 1404

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 timer when signout.

Please help me for this.

thanks in advance

Upvotes: 0

Views: 2219

Answers (3)

hcb
hcb

Reputation: 8357

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.

Upvotes: 0

Tigran
Tigran

Reputation: 62256

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.

Upvotes: 0

SLaks
SLaks

Reputation: 887469

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

Upvotes: 1

Related Questions