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 7563311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:38:04+00:00 2026-05-30T13:38:04+00:00

I have a Windows Service that overrides the OnStart and OnStop methods to call

  • 0

I have a Windows Service that overrides the OnStart and OnStop methods to call a class library. I’m using a producer/consumer model (see http://www.albahari.com/threading/part4.aspx#_Wait_Pulse_Producer_Consumer_Queue for where I got the idea/logic).

The problem I’m having is the Action isn’t correctly running for some reason. Here’s the “(System.)Action” code (inside the timer_elapsed):

_queue.EnqueueItem(() =>
{
    BuildFile file = new BuildFile();
    file.run();

    _writer.WriteLine("Gets Here: {0}", DateTime.Now.ToString());
    _writer.Flush();
});

As you can probably see, the _writer is basically a “debug” logging tool. It DOES write that line out to the file whenever it is called (the Windows Service runs off a timer):

_timer.Interval = 30000; //(3600000)
_timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
_timer.Enabled = true;

For a test, the VERY first call that is made for BuildFile is a simple log to the database:

public BuildFile()
{
   logEntry("Success", "I'm Running...");
}

but the log entry never gets written (the method works fine elsewhere).

The weirdest part is when I wrap the class with a Console app, it works fine. The code is exactly the same in the Windows Service, but it just won’t fire the BuildFile stuff.

Has anyone seen anything like this?

  • 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-30T13:38:06+00:00Added an answer on May 30, 2026 at 1:38 pm

    The console app and the service app are most likely running under different accounts. Make sure the service account has access to the file system path. Also, if you are using Windows Authentication for the database you need to look into that as well.

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

Sidebar

Related Questions

I've create a Windows Service using C# that when OnStart is called creates a
I have a C# Windows Service. The OnStart() method contains 3 lines that all
I have a Windows Service that is meant to run a 2-minute job once
I have a windows service that runs various system monitoring operations. However, when running
I have a windows service that runs fine, but I have to have it
I have a Windows service that runs implementations of a framework across multiple threads.
I have a windows service that has a custom configuration section. In the configSectionHandler
I have a Windows service that runs as a logged-in user (local admin). During
I have a Windows Service that takes the name of a bunch of files
I have a windows service that generates logs as it does some execution. 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.