Does using Timer class features (System.Timers) cost a Windows service?

Asked

Viewed 625 times

7

I need to do a database check once a day.

I’m thinking of using the class Timer (System.Timers). The time contactor feature will burden/lock the other system services?

This solution is advisable within a service Windows?

System: C#, Windows Service Project, event that triggers the timer: OnStart().

1 answer

6


No, class is made for what you want. With it you will "sign an event" with the operating system and a flag will be sent to your application when given the given time and will transfer control to the code determined by you as soon as possible. So it doesn’t keep counting the time, it doesn’t consume processing while waiting for the event to occur. It just observes an external event.

There may even be better solutions depending on what you want, but I’m trusting that what you need is something that only Timer resolve. You may not even need a specific application for this. You can do something simpler, maybe even a script to be scheduled in the operating system. Anyway, without knowing exactly your need I can not speak of an ideal solution. For what you posted, I think it’s answered.

  • Dear Bigown! The idea is that when reaching the given time the service check if the password of the service that it offers is expiring. If yes it changes the password automatically and sends email warning of the change to interested parties. I believe you answered precisely what you wanted to know, thank you very much!

  • Without all the details it is clear that it is impossible to make definitive statements but it may be that conceptually (not necessarily simpler or better) it could be interesting to configure the server to notify your application in a given situation (if your DB has this feature) and waive the timer, so it stays on-demand same, ie, your application is only invoked when it is really necessary. But there is already another subject.

  • @Marconi understood, I will delete the comments because they help in anything the answer, turned chat :) I suggest doing the same.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.