Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 386025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:32:12+00:00 2026-05-12T15:32:12+00:00

I found this post, windows service startup timeout But just wanted to clarify, I

  • 0

I found this post,

windows service startup timeout

But just wanted to clarify, I have written a windows service in C# .NET that gives timeout errors at times, e.g.

A timeout was reached (30000 milliseconds) …. when starting the service

The reason is it does some WCF stuff in the start up method which works fine most of the time, but if your computer is bogged down on startup for instance it can cause it to take a bit longer. I realise now that the code shouldn’t be structured like that.

Is an acceptable solution to start a background thread from the startup method and finish doing the WCF stuff in there?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:32:13+00:00Added an answer on May 12, 2026 at 3:32 pm

    Like all applications, a Windows service has an entry point. In C#, this is called Main() and is a static method on some class. Inside the Main() function of your Windows service, you should have something akin to this:

    ServiceBase[] ServicesToRun = new ServiceBase[] { new MyWindowsService() };
    ServiceBase.Run( ServicesToRun );
    

    In this example, MyWindowsService is the name of the Windows service class to run and should be replaced with whatever your Windows service class name is.

    When this code is executed in Main(), the default constructor for your Windows service class will be called, which looks something like this:

    public MyWindowsService()
    {
        // service instance initialization goes here...
    }
    

    This is where you would initialize the MyWindowsService instance.

    Now, the MyWindowsService class should be derived from System.ServiceProcess.ServiceBase. If that is true, then you can override the OnStart() method, which is called when a Start command is sent to the service by the Service Control Manager.

    protected override void OnStart(string[] args)
    {
        // things to do when starting the service...
    }
    

    Once the OnStart() function returns, your service is effectively running, i.e., started.

    So, the question is where along this chain of events your delay is occurring – in Main(), the service constructor, or the OnStart() callback method. Have you tried debugging your service? An easy way to do this is to place the following line of code inside the Main() function of your service:

    System.Diagnostics.Debugger.Break();
    

    When you start the service, you will be prompted to select a debugger. Simply select a new instance of Visual Studio, and you’ll jump right into the code at the point where this Break() call is made. You can debug from there, setting breakpoints in the pertinent places (constructor, OnStart()) to see where the hangup is occurring.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have modified a working Windows service that had always been starting beforehand. After
I've built a WCF Service in .NET 4.0 that basically just does standard CRUD
I have an application written in VB.NET ( NOT asp.net, it is a Windows
I have created a windows service which allows communications via namedpipes. This code worked
I found this open-source library that I want to use in my Java application.
I found this link http://artis.imag.fr/~Xavier.Decoret/resources/glsl-mode/ , but there isn't a lot of description around
I found this in an article on Multithreaded Apartments, but can’t find a definition
Just found this out, so i am answering my own question :) Use a
I found this PECL package called threads , but there is not a release
I found this: http://www.evolt.org/failover-database-connection-with-php-mysql and similar examples. But is there a better way? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.