c# - System.Timer synchronization not working -


I have created a window service that will throw an event at every T interval. This event will consume a web service and call its web method. This windows service does not know how long the web method will take to complete the execution.

What I see is that when the gap is over, more than one instance of the web method is going on. I am using the counter but it is not working. I do not want to overlap the web method execution.

Public partial class autoconfiguration: servicebase {personal timer timer = zero; Private Bull is running counterfault = false; Public Autolocation () {InitializeComponent (); } Safe override zero start (string [] args) {timer = new timer (); String TimerInterval = Configuration Manager App Settings ["Time Interval"]; Timer Interval = convert Noon (timerinval); Timer Elapsed + = New System Timer EspladeeventHandler (this.TimerTick); Timer Competent = true; } Private Zero TimerTech (Object Sender, ElapsedEventArgs e) {if (runningCounter == false) {runningCounter = true; Employee Management Services Resources Mgmt = New Employee Management Service (); ResourceMgmt.AutoAllocateSalary (); RunningCounter = false; }}

Try setting it to false.

This means that the timer will set a fire and will not come into the fire until you start it manually, which you can do after your website call.

For example:

  protected override zero onstart (string [] args) {string timerInterval = ConfigurationManager.AppSettings ["TimeInterval"]; Timer = new timer (); Timer.AutoReset = false; Timer Interval = convert Noon (timerinval); Timer Elapsed + = New System Timer EspladeeventHandler (this.TimerTick); Timer.start (); } Private Zero TimesTech (Object Sender, ElapsedEventArgs E) {EmployeeManagementService Resources Mgmt = new EmployeeManagementService (); ResourceMgmt.AutoAllocateSalary (); (Timer) Sender) .start (); }  

This will prevent any overlapping of the call, which is likely to happen here.

Also remember that the interval milliseconds so if you are supplying seconds, make sure its * 1000 .


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -