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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:33:10+00:00 2026-06-07T00:33:10+00:00

here i am using window service, using a logic as my service will work

  • 0

here i am using window service, using a logic as my service will work only once in the 24 hours by with the help of have configured in the app.config.

Ex : i will mention hour in app config as “10” so daily once my service will run by exactly 10 clock

But problem is when i start my service, it was throwing an error as 1053(Timely fashion error) and status it was showing as Starting in services.msc, no more start and Restart functions are not shown in the popup window of right click

wondering is it was done the job perfectly,by ten o clock exactly.

why it was not shown as started, why it was throwing an error?

i have pasted the sample code bellow and kindly advice whether if i did any wrong

on start method

protected override void OnStart(string[] args)
{
     DateTime tenAM = DateTime.Today.AddHours(strSETHOST);


     if (DateTime.Now > tenAM)
          tenAM = tenAM.AddDays(1);


     // calculate milliseconds until the next 10:00 AM.  
     int timeToFirstExecution = (int)tenAM.Subtract(DateTime.Now).TotalMilliseconds;

     // calculate the number of milliseconds in 24 hours.   
     int timeBetweenCalls = (int)new TimeSpan(24, 0, 0).TotalMilliseconds;

     TimerCallback methodToExecute = kickstart;

     // start the timer.  The timer will execute "ProcessFile" when the number of seconds between now and   
     // the next 10:00 AM elapse.  After that, it will execute every 24 hours.   
     System.Threading.Timer timer = new System.Threading.Timer(methodToExecute, null, timeToFirstExecution, timeBetweenCalls);

     Thread.Sleep(Timeout.Infinite);

 }

 protected override void OnStop()
 {
 }

 public static void kickstart(object nowtime)
 {

      Service1  foo = new Service1();
      foo.Startjob();
 }

 private void Startjob()
 {
      using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew)) // Transaction Scope Started
      {
           if ((threadPURGE == null) || (threadPURGE.ThreadState == System.Threading.ThreadState.Stopped) || (threadPURGE.ThreadState == System.Threading.ThreadState.Unstarted) || (threadPURGE.ThreadState == System.Threading.ThreadState.Aborted))
           {
                threadPURGE = new Thread(new ThreadStart(DynamicThreadGen));  // Thread Initialize for ITD 
           }

           try
           {
                if ((threadPURGE == null) || (threadPURGE.ThreadState == System.Threading.ThreadState.Stopped) || (threadPURGE.ThreadState == System.Threading.ThreadState.Unstarted) || (threadPURGE.ThreadState == System.Threading.ThreadState.Aborted))
                {
                     threadPURGE.Start();  // Thread Started for ITD 
                }


           }
           catch (Exception ex)
           {
                string err = ex.Message.ToString();
           }
           finally
           {
                scope.Complete();
           }
      }

 }

 private void DynamicThreadGen()
 {
     /// service work 
 }
  • 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-07T00:33:12+00:00Added an answer on June 7, 2026 at 12:33 am

    You need to allow your OnStart method to complete within a Windows allocated timeout, otherwise Windows can’t tell that it has started. Hold on to the Timer in a class field so it does not get garbage collected and disposed, then ditch the Thread.Sleep

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

Sidebar

Related Questions

To help better explain my Question, here is what i have: I am using
am trying to calculate mean and variance using 3X3 window over image(hXw) in opencv...here
I have implemented Apple Push Notification service using Urban Airship and successfully received the
.NET 3.5, VS2008, WCF service using BasicHttpBinding I have a WCF service hosted in
I have this requirement of Uploading 1000s of Photos from a window application. Logic
I have a wcf service that is secured using WIF. I'm implementing token caching
I have to call the web service using java script? e.g. I'm creating one
I have a call to a service using ajax, i would like if everything
I have created a WCF webservice using WCF Service Application template in VS 2008.
I'm using Windows 7 and PowerGUI Script Editor to write a ps1. Here's a

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.