The stuff leading up to PollProcess() as shown here is shown below:
using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;
namespace FooStuff
{
partial class FooService : ServiceBase
{
private Thread m_oPollingThread = null;
public FooService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("Foo service started");
if (m_oPollingThread == null)
m_oPollingThread = new Thread(new ThreadStart(PollProcess));
m_oPollingThread.Start();
}
protected override void OnStop()
{
eventLog1.WriteEntry("Foo service is stopping.");
m_oPollingThread.Abort();
}
private void PollProcess()
{
We are using that corny, confusing Designer.cs antipattern and here is what is in the designer:
namespace FooStuff
{
partial class FooService
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.eventLog1 = new System.Diagnostics.EventLog();
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
this.eventLog1.Log = "Application";
this.eventLog1.Source = "Foo";
this.ServiceName = "FooService";
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();
}
private System.Diagnostics.EventLog eventLog1;
}
}
I don't really understand the ServiceBase base class yet as of this writing. I am running this service at a server. I installed it will an installer. When I type "services" at the start menu at that server, I get the "Component Services" dialog box. At the left, I can expand "Event Viewer (Local)" and then "Windows Logs" beneath it and then click on "Application" to browse a list of errors for the service.
No comments:
Post a Comment