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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:54:30+00:00 2026-05-10T21:54:30+00:00

Which is the best timer approach for a C# console batch application that has

  • 0

Which is the best timer approach for a C# console batch application that has to process as follows:

  1. Connect to datasources
  2. process batch until timeout occurs or processing complete. ‘Do something with datasources’
  3. stop console app gracefully.

related question: How do you add a timer to a C# console application

  • 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. 2026-05-10T21:54:31+00:00Added an answer on May 10, 2026 at 9:54 pm

    Sorry for this being an entire console app… but here’s a complete console app that will get you started. Again, I appologize for so much code, but everyone else seems to be giving a ‘oh, all you have to do is do it’ answer 🙂

    using System; using System.Collections.Generic; using System.Threading;  namespace ConsoleApplication1 {     class Program     {         static List<RunningProcess> runningProcesses = new List<RunningProcess>();          static void Main(string[] args)         {             Console.WriteLine('Starting...');              for (int i = 0; i < 100; i++)             {                 DoSomethingOrTimeOut(30);             }              bool isSomethingRunning = false;              do             {                 foreach (RunningProcess proc in runningProcesses)                 {                     // If this process is running...                     if (proc.ProcessThread.ThreadState == ThreadState.Running)                     {                         isSomethingRunning = true;                          // see if it needs to timeout...                         if (DateTime.Now.Subtract(proc.StartTime).TotalSeconds > proc.TimeOutInSeconds)                         {                             proc.ProcessThread.Abort();                         }                     }                 }             }             while (isSomethingRunning);              Console.WriteLine('Done!');                  Console.ReadLine();         }          static void DoSomethingOrTimeOut(int timeout)         {             runningProcesses.Add(new RunningProcess             {                 StartTime = DateTime.Now,                 TimeOutInSeconds = timeout,                 ProcessThread = new Thread(new ThreadStart(delegate                   {                       // do task here...                   })),             });              runningProcesses[runningProcesses.Count - 1].ProcessThread.Start();         }     }      class RunningProcess     {         public int TimeOutInSeconds { get; set; }          public DateTime StartTime { get; set; }          public Thread ProcessThread { get; set; }     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 92k
  • Answers 92k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No. Not all clients hash the same way. As evidence… May 11, 2026 at 6:32 pm
  • Editorial Team
    Editorial Team added an answer $("#item_select").change(function(){ var params = $("#item_select option:selected").val(); $.post('/account/ar_form.php', {idata: params}, function(data){… May 11, 2026 at 6:32 pm
  • Editorial Team
    Editorial Team added an answer Alas, no, see http://www.aspdeveloper.net/Virtual_PC/rn-739-16434_Virtual_PC_API.aspx . May 11, 2026 at 6:32 pm

Related Questions

We need to optimize the text rendering for a C# Windows Forms application displaying
If I have a variable in C# that needs to be checked to determine
In a C++ application that can use just about any relational database, what would
The platform isn't really as important as the theory. For the record, it is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.