I wrote my first windows service.
- Create a WS Project
- Rename Service
- Drag the timer to the middle
- Turn it on, tick to 1 s
- Create a logfie in teak if it does not exist
- Install service
- Start the service
Nothing happens...
I try to connect to the service, it loads correctly, but with a breakpoint in it, it never hits.
Any ideas?
Code Timer:
private void timMain_Tick(object sender, EventArgs e)
{
if (!File.Exists("C:/test.txt"))
File.Create("C:/test.txt");
}
Code initialization:
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.timMain = new System.Windows.Forms.Timer(this.components);
this.timMain.Enabled = true;
this.timMain.Interval = 1000;
this.timMain.Tick += new System.EventHandler(this.timMain_Tick);
this.CanShutdown = true;
this.ServiceName = "AuctionService";
}
One word: File.Create only to check if the timer. Because of this, I was a little irrelevant =)
source
share