Need to be written together with window's setup program
Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.diagnostics;using system.linq;using system.serviceprocess;using system.text;using Inspur.dataexchange.logging;using system.configuration;using Inspur.finix.exceptionmanagement;namespace wenzhouzj.exchange.fromnw{public partial class Service1:servicebase {private System.Timers.Timer timer2; Public Service1 () {this.timer2 = new System.Timers.Timer (); ((System.ComponentModel.ISupportInitialize) (This.timer2)). BeginInit (); This.timer2.Enabled = true; This.timer2.Interval = 1 * 1000; this.timer2.Elapsed + = new System.Timers.ElapsedEventHandler (this.timer2_elapsed); ((System.ComponentModel.ISupportInitialize) (This.timer2)). EndInit (); This. ServiceName = "Wenzhou Quality supervision and data interchange with South Wei, receiving Information Acquisition service"; } protected override void OnStart (string[] args) {//this.timer1.enabled = fAlse; } protected override void OnStop () {this.timer2.Enabled = false; } private void Timer2_elapsed (object sender, System.Timers.ElapsedEventArgs e) {//If the set run time has elapsed String runtime = configurationsettings.appsettings["Runtime"]; if (string. IsNullOrEmpty (runtime) | | Runtime. Equals (DateTime.Now.ToString ("hh:mm"))) {this.timer2.Enabled = false; try {//dataexchange.doexchange (); Periodically executed event} catch (Exception ex) {Exceptionmanager.handle (E x); } This.timer2.Interval = Convert.todouble (system.configuration.configurationsettings.appsettings["Interval" ]) * 60 * 1000; This.timer2.Enabled = true; } } }}