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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:49:06+00:00 2026-06-15T00:49:06+00:00

I developed a Windows service using vb.net which does the following using OnStart Even…

  • 0

I developed a Windows service using vb.net which does the following using OnStart Even…

  • Grabs all Entries from a SQL Table
  • Creates Schedules from returned rows

it works fine, schedules fire on their time and stuff.

Problem: Whenever I have to ADD a new row to my Table, I have to restart the Service, So it can Grab the Newly created rows. This is causing problems for me…there could be a task which is running already and restarting service might break the system.

So what is the best way to handle this? Can the new rows be loaded into Service without a restart?

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-06-15T00:49:09+00:00Added an answer on June 15, 2026 at 12:49 am

    This OnStart was provided here by Marc Gravell:

    public void OnStart(string[] args) // should this be override?
    {
        var worker = new Thread(DoWork);
        worker.Name = "MyWorker";
        worker.IsBackground = false;
        worker.Start();
    }
    void DoWork()
    {
        // do long-running stuff
    }
    

    Note that OnStart can launch multiple threads or the first thread started may be used to start additional threads as needed. This allows you to set up either database polling or a thread that waits on a message queue for data.


    A useful tip:

    Adding a Main to your service allows you to run it as a console application in Visual Studio. This greatly simplifies debugging.

        static void Main(string[] args)
        {
            ServiceTemplate service = new ServiceTemplate();
            if (Environment.UserInteractive)
            {
                // The application is running from a console window, perhaps creating by Visual Studio.
                try
                {
                    if (Console.WindowHeight < 10)
                        Console.WindowHeight = 10;
                    if (Console.WindowWidth < 240) // Maximum supported width.
                        Console.WindowWidth = 240;
                }
                catch (Exception)
                {
                    // We couldn't resize the console window.  So it goes.
                }
    
                service.OnStart(args);
                Console.Write("Press any key to stop program: ");
                Console.ReadKey();
                Console.Write("\r\nInvoking OnStop() ...");
                service.OnStop();
    
                Console.Write("Press any key to exit: ");
                Console.ReadKey();
            }
            else
            {
                // The application is running as a service.
                // Misnomer.  The following registers the services with the Service Control Manager (SCM).  It doesn't run anything.
                ServiceBase.Run(service);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I developed a Windows service using C#.NET to generate PDF report. To generate PDF
I have developed a .NET UI and windows service which communicate with each other
I have developed a windows service using visual studio 2008 and .net fw 3.5.1
Few years ago I've developed a windows service app (VB.NET framework 1.1) which was
I have developed a Windows service using Visual Studio 2008. I want to install
Hi We developed web service using WCF service and hosted on Windows 2003 server
I have a simple windows Service developed in VS.net 2008 and VB.net. When I
I have a .net Windows Service developed in VB.net. I have a settings file
I have a very simple windows Service that is developed in vb.net 2008. When
I have a site developed in ASP.NET and hosted on a windows server using

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.