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

  • SEARCH
  • Home
  • 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 8881269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:18:38+00:00 2026-06-14T20:18:38+00:00

I have written a windows service which in turn calls a web service. When

  • 0

I have written a windows service which in turn calls a web service. When I run the windows service from a test app., it works perfectly. However when I install the service and then start it, it stops almost immediately. The only two entries I see in the log are Constructor and Thread Started. Not sure what is wrong.

public partial class WindowsService : ServiceBase
{
    public LogManager.LogFile _log;
    public Thread m_thread;
    protected TimeSpan m_delay;

    CommonFunctions _cf = new CommonFunctions();
    DBFunctions _db = new DBFunctions();

    public WindowsService()
    {
        InitializeComponent();
        _log = new LogManager.LogFile(@"c:\test\servicelog.txt", true, true);
        _log.WriteToLog("Constructor", LogLevel.Level0);
    }


    protected override void OnStart(string[] args)
    {

       m_delay = new TimeSpan(0,0,300);
       base.OnStart(args);

        try
        {
            m_thread = new System.Threading.Thread(Execute);
            m_thread.Start();
            _log.WriteToLog("Thread Started", LogLevel.Level0);
        }
        catch (Exception ex)
        { _log.WriteToLog(ex.Message, LogLevel.Level0); }

    }

  public void Execute()
    {
        _log.WriteToLog("Begin Execute...", LogLevel.Level0);

        try
        {

            ProcessNewLMSUsers();

         }
        catch (Exception ex)
        {
             _log.WriteToLog(ex.Message.ToString());
        }

     }

    private void ProcessNewLMSUsers()
    {
        try
        {
            _log.WriteToLog("Begin: Processing new LMS Users", LogLevel.Level1);

            // Check for new users in the LMS.
            string callErrorText = "";
            bool userAdded = false;

            LMSWS.SSO lms = _cf.GetLMSSSOWS(); **// this is a web service**
            lms.Timeout = 99999;


          }

             REST OF THE CODE.................
     }
  • 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-06-14T20:18:40+00:00Added an answer on June 14, 2026 at 8:18 pm

    I can’t see there is anything wrong with your code. but you can try to put a “Thread.Sleep(20000); ” code at the begining of OnStart method. e.g.

    protected override void OnStart(string[] args)
    {
       Thread.Sleep(20000); 
    
       m_delay = new TimeSpan(0,0,300); //set a break-point here
       base.OnStart(args);
    
        try
        {
            m_thread = new System.Threading.Thread(Execute);
            m_thread.Start();
            _log.WriteToLog("Thread Started", LogLevel.Level0);
        }
        catch (Exception ex)
        { _log.WriteToLog(ex.Message, LogLevel.Level0); }
    
    }
    

    and once you start this service program in Windows Service, then you have to quickly attach you source code to the service program. In visual studio, it’s menu “Debug” -> “Attach to Process…”. then you can set break-point in your source code anywhere to check what’s going wrong.

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

Sidebar

Related Questions

I have written a Windows service which should turn the display OFF when certain
I have a Windows Service written in .NET C# which calls a COM component.
I have written a Windows Service which listens for data from a third party
I have a windows service written in c# which reads the text from word
i have a windows service written in .net 4 which doing jobs periodically using
I have written a Windows service to collect information from all of our SQL
I have a windows service, written in c# and I need to run a
I have written a .NET Windows service which has a WCF service built into
I have written a windows service application which is installed on my PC. There
I have a windows service written in c#. It has a timer inside, which

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.