Creating a contructor and destructor for a simple class that is called in a Windows Service
Posted on 2008-11-04
I'm trying to put together a Windows Service that checks a registry key. It will use an infinite FOR loop and sleep for two minutes.
The code already compiles and runs as a Windows Console application. The program.cs of the Console program looks like this:
static void Main(string args)
RegCheck RC = new RegCheck();
Considering this is the code for a service:
protected override void OnStart(string args)
// TODO: Add code here to start your service.
protected override void OnStop()
// TODO: Add code here to perform any tear-down necessary to stop your service.
What would I have to do to run a thread for this class? This brings me to the constructor and destructor of my RegCheck class - I don't have any. The class has one method RunRegUpdate() which does the check and ends - some 80 lines.
Do I need a constructor and destructor for this class? How about for the Service, what's necessary to put this all together right?