private void onIntervalExpired(object sender, EventArgs e) { //Event handler for self timed operation try { if (this.mStartup) { //Set startup condition- create utility service this.mStartup = false; this.mTimer.Interval = getTimerInterval(); initServices(); } if (!this.mShutdown) { //Run the service this.mIcon.Text = "File Utility running..."; for (int i = 0; i < this.mSvcs.Length; i++) { FileSvc oSvc = this.mSvcs[i]; oSvc.Execute(); } } else { //Shutdown condition this.mTimer.Enabled = false; this.Close(); } } catch (Exception ex) { FileLog.LogMessage("TIMER ERROR\t" + ex.Message); } finally { setServices(); } }
private void OnFormLoad(object sender, System.EventArgs e) { //Event handler for form load try { //Hide this.Visible = false; //Timed or one shot if (this.mUseTimer) { //Log application as started; start the scheduler FileLog.LogMessage("UTILTIY STARTED (TIMER=" + getTimerInterval().ToString() + "msec)"); this.mStartup = true; this.mTimer.Interval = 100; this.mTimer.Enabled = true; } else { //Log application as started; create service instances; run one shot and shutdown FileLog.LogMessage("UTILTIY STARTED (TIMER=OFF)"); initServices(); for (int i = 0; i < this.mSvcs.Length; i++) { FileSvc oSvc = this.mSvcs[i]; oSvc.Execute(); } this.Close(); } } catch (Exception ex) { FileLog.LogMessage("STARTUP ERROR\t" + ex.Message); } }