473,651 Members | 3,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3356
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******@hotma il.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******@hotma il.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
3010
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 delegate inside the UI that I call to update the progress meter. I use the Suspend() and Abort() methods based on button events. I can watch the progress meter increase just fine when the thread is running. When I select Start, I enable the Cancel...
6
8752
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 talk to the UPS over a special device driver. Through this device driver I can detect that the UPS is going to notify Windows 2000 server to shut down. So I start doing a graceful termination. But Windows shuts down pretty quickly and there...
4
2520
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 performance - except when the application first starts. When hitting my Web server over the Internet there is a delay waiting for the first page. I suspect that the App Pool is starting up as well as my particular ASP.NET Web application. I should note that...
7
2182
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 there a known issue with this or am i doing something dumb? im using the following code: what im attepting to do is when a user exits a combo box, the app retrieves the highest id, then adds 1 and displays it the problem is that if the users...
18
3251
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 function from kernel32 to accomplish this? My concern is that this function takes milliseconds where my program needs to be accurate to within 5 minuets, and delays may be as long as a number of days, months or whatever. Would I run into many problems...
7
1323
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 time of this application to start. Sometimes it's more or less instant, other times it can be over 15 seconds. My initial thought was that the .Net Framework may not have been loaded, but we have a another .Net application running on the server...
0
1694
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. After that, the response time on subsequent calls is nearly intantaneous. As an example, If I'm debugging and press <F5I'll get the 30 second delay on first invocation, then it's fast after that. If I stop the program and restart (F5), I get...
2
5886
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 receiving and properly parsing a response, but the problem is that when I step through it in the debugger (or even when I run the executable) there is a delay of about 15 seconds after executing my XXXAsync method to invoke the web service until...
6
14476
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 very fast. What is happening during this initial delay, and is there anything I can do to fix this so my applications start up quickly? For example, typically the first call to consuming a webservice is some sort of 'login / authenticate'...
0
8361
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8701
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.