473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Delay starting Win Service

I have a Windows Service and in the OnStart, I am
initializing the BusinessLayer Object and calling a method
of the object, which normally takes about 10 mts to finish
execution.

Now when I start the Service from Administrative Tools
services, it shows starting and after sometime throw error
that the service does not respond in time and the ststus
is shown as "starting". However during this time, the
BisObject is doing its job and finally when it is done the
status shows as started.

Is OnStart the right place to call the BisObject. Is there
a better way of doing this. May be a new thread for the
BisObject. In which case, How do I close that thread. What
is the best prctice to follow in this situation.

Thanks,

Rajesh Abraham Chacko
Nov 15 '05 #1
2 3344
As you said, start a new thread from OnStart. You don't need to do anything
special to close the thread, just let it do its job in thread's Start()
method.

Eliyahu

"Rajesh Abraham" <ch******@hotmail.com> wrote in message
news:02****************************@phx.gbl...
I have a Windows Service and in the OnStart, I am
initializing the BusinessLayer Object and calling a method
of the object, which normally takes about 10 mts to finish
execution.

Now when I start the Service from Administrative Tools
services, it shows starting and after sometime throw error
that the service does not respond in time and the ststus
is shown as "starting". However during this time, the
BisObject is doing its job and finally when it is done the
status shows as started.

Is OnStart the right place to call the BisObject. Is there
a better way of doing this. May be a new thread for the
BisObject. In which case, How do I close that thread. What
is the best prctice to follow in this situation.

Thanks,

Rajesh Abraham Chacko

Nov 15 '05 #2
Rajesh,

You are on the right track with the thread idea. The OnStart must
finish within the alloted time so you shouldn't put any processing
code there.

I've seen this problem handled two ways. The first and most
straightforward is to instantiate an object in the OnStart and spawn a
new thread using a method of this main object. This will allow the
OnStart to complete in a timely fashion.

The second method is to create a timer object and set it to expire
once with a very short time. You can then put the processing code in
the elapsed event. This will allow the OnStart to complete. Behind
the scenes, the processing of the timer runs on a separate system
thread and because an event raised in a thread will be handled in that
thread no matter in which object it is defined, the elapsed event will
run in the system thread as well. This approach is actually doing the
same thing as the first approach, it is just hiding the threads.

Hope this helps
"Rajesh Abraham" <ch******@hotmail.com> wrote in message news:<02****************************@phx.gbl>...
I have a Windows Service and in the OnStart, I am
initializing the BusinessLayer Object and calling a method
of the object, which normally takes about 10 mts to finish
execution.

Now when I start the Service from Administrative Tools
services, it shows starting and after sometime throw error
that the service does not respond in time and the ststus
is shown as "starting". However during this time, the
BisObject is doing its job and finally when it is done the
status shows as started.

Is OnStart the right place to call the BisObject. Is there
a better way of doing this. May be a new thread for the
BisObject. In which case, How do I close that thread. What
is the best prctice to follow in this situation.

Thanks,

Rajesh Abraham Chacko

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Doug Thews | last post by:
I ran into an interesting re-pain delay after calling the Abort() method on a thread, but it only happens the very first time I call it. Every time afterward, there is no delay. I've got a...
6
by: carbon_dragon | last post by:
Ok, so here is the problem. I'm working on a headless server program implemented as a .NET C# Console project. There is a UPS mounted to this server (though not a windows compliant UPS). I can only...
4
by: Jeremy S | last post by:
I have written an ASP.NET application that performs very well. I make heavy use of the Cache and otherwise minimize the number of round trips to to the db. I couldn't be happier with the...
7
by: T Perkins | last post by:
no matter how i code it, there is always 3-5 second pause on retrieving data from an sql 2000 server. this pause only happens on the first try, after that every access is back to being normal. is...
18
by: Max | last post by:
This is a follow-up on my previous thread concerning having the program wait for a certain date and time and then executing some code when it gets there. My question is; can I use the Sleep...
7
by: Jason Ratcliffe | last post by:
Hi, We've got a small .net application launcher which is run each time a user connects to our terminal services server instead of the standard shell. We found that it takes a variable amount of...
0
by: bdtmike | last post by:
I'm using VS2005 and creating a VB.Net Winforms app. The app uses a couple of web services. For some reason, when I start the app, there is a 30 second delay when VB invokes its first web service....
2
by: beachdog | last post by:
I have built a web service consumer application by adding a web reference for a vendor-provided wsdl file. My client is interoperating with the server just fine, in terms of sending a request and...
6
by: DaveOnSEN | last post by:
Every time I make any .NET framework based webservice consumer I have the same problem: The first call my application makes to consume a webservice takes about 15 seconds. Subsequent calls are...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.