I designed a windows service in C#, and it takes time to start (60-70 sec). I was wondering does it generally take that long to start? It is my code which is taking that much time?
I have two threads which runs every 6 seconds and 1 minute.
And if it takes that much time, can somebody tell me why it takes that much time. Not in detail just an overview.
If your service does alot of work during startup (service.OnStart), it will take a long time to start.
Defer the work to another thread if you want the service to startup immediatly.
This assumes that normal service startup is pretty much immediate.
Like Oded said,
protected override void OnStart(string [] args)
{
System.Threading.Thread workerThread =new System.Threading.Thread(longprocess());
workerThread.start();
}
private void longprocess()
{
///long stuff
}
Although this will make your service to startup quickly it will not gurantee that longprocess() will be done quickly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With