To create Windows service, create a class that inherits from System.ServiceP rocess.ServiceB ase, System.ServiceP rocess
http://msdn.microsoft.com/library/de...classtopic.asp
For info on printing using .NET:
http://msdn.microsoft.com/library/de...asp?frame=true
Here's an example:
Start a timer when the service is started to perform some action every n milliseconds:
public class MyService : System.ServiceP rocess.ServiceB ase
{
private System.Threadin g.Timer timer;
/// <summary>Main entry point of the application. (*.exe)</summary>
public static void Main()
{
using (MyService service = new MyService())
{
// Blocks the thread until the serivce is stopped by a service controller. (You can go to services in administrative
tools, select your service, and click Stop)
System.ServiceP rocess.ServiceB ase.Run(service );
}
}
public MyService()
{
// tell the service control manager what operations can be performed on our service
CanShutdown = CanPauseAndCont inue = CanHandlePowerE vent = false;
CanStop = true;
}
public override void OnStart(string[] args)
{
timer = new Timer(new System.Threadin g.TimerCallback (Poll), null, 0, 10000); // Poll every 10 seconds
// return immediately so the serivce controller knows that your service started successfully.
// You have 30 seconds to return from this method or the serivce will be stopped automatically by the SCM.
}
/// <summary>Call ed on a thread-pool thread at the specified interval. Do not process any asyncronous calls.</summary>
private void Poll(object state)
{
// do your polling here
if (hasStuffToPrin t)
Print(stuffToPr int);
}
/// <summary>Call ed on a thread-pool thread. Do not process any asyncronous calls.</summary>
private void Print(object stuffToPrint)
{
// do your printing here.
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (timer != null)
timer.Dispose() ;
}
}
}
Good luck :)
--
Dave Sexton
dave@www..jwaon line..com
-----------------------------------------------------------------------
"Chris" <Ch***@discussi ons.microsoft.c om> wrote in message news:DD******** *************** ***********@mic rosoft.com...
Hi,
I need to create a windows service that will poll a database every 10 sec
and print processed orders to a printer. Where can I find info on this?
Thanks