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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:23:14+00:00 2026-05-30T23:23:14+00:00

How do i get the count in the reverse order? Right now, i have

  • 0

How do i get the count in the reverse order? Right now, i have displayed the number of count’s done.. But i also want the number of counts left. And how do i reset the timer at end of each day in the below program and display the last time it was executed? Could someone help me with the whole program?
The program is –

namespace Time_Writer
{
  class Program
  {
    static int count = 1;
    static double seconds;
    private static System.Timers.Timer aTimer;


    static void Main(string[] args)
    {
        ReadCountFromFile();


        aTimer = new System.Timers.Timer();
        aTimer.Elapsed +=new System.Timers.ElapsedEventHandler(aTimer_Elapsed);
        aTimer.Interval = 5000;
        aTimer.Enabled = true;
        Console.WriteLine("Press Enter To Exit The Program\n");
        Console.ReadLine();


        AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);


    }
    private static void ReadCountFromFile()
    {
        try
        {
            if (File.Exists(".\\mynumber.dat"))
            {
                using (var file = File.Open(".\\mynumber.dat", FileMode.Open))
                {
                    byte[] bytes = new byte[4];
                    file.Read(bytes, 0, 4);
                    count = BitConverter.ToInt32(bytes, 0);
                    Console.WriteLine("Limit = 10000");
                    Console.WriteLine("Count  = {0}", count);

                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("Problem reading file.");
        }
    }
    static void CurrentDomain_ProcessExit(Object sender, EventArgs e)
    {
        using (var file = File.Open(".\\mynumber.dat", FileMode.OpenOrCreate))
        {
            var buffer = BitConverter.GetBytes(count);
            file.Write(buffer, 0, buffer.Length);
        }
    }
    private static void aTimer_Elapsed(object source, ElapsedEventArgs e)
    {
        Console.WriteLine("Name is Yap {0}", e.SignalTime);
        seconds += 5;
        count += 1;
        if (count>10000 || seconds==86400)
        {
            aTimer.Enabled = false;
            Console.WriteLine("\n\nTimer is off at {0}\n\n", e.SignalTime.TimeOfDay.ToString());
        }
     }
   }
 }
  • 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-30T23:23:15+00:00Added an answer on May 30, 2026 at 11:23 pm

    Do you mean something like this?

    Console.WriteLine("Limit = 10000");
    Console.WriteLine("Count: {0} of 10000. {1} remaining", count, 10000 - count);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get a count of the number of files in a directory.
I want to know how we can get record count using reference cursor in
How to query to get count of matching words in a field, specifically in
How to get the count of total values defined in an enumeration?
I need to get a get a count of all the distinct subnets in
Is there a way to get the count of rows in all tables in
Is there any easy way using the api to get a count of all
How do I get the row count of an internal table? I guess that
I'm trying to write a reverse relationship for taking the number of answers asociated
The basics of this query have been asked, and answered, many times before, but

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.