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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:18:02+00:00 2026-05-27T18:18:02+00:00

In my projects main form I establish a timer which calls on an object

  • 0

In my projects main form I establish a timer which calls on an object of a different class to set its intervals.

    Clock.Interval = formSettings.GetTimeInTicks();
    Clock.Tick += new EventHandler(TimerEventProcessor);
    Clock.Start();

The time intervals is a setting in my Settings class. When the user chooses a new time from the combobox of times, I want it to restart the Clock that is established in my Main form/class, and use the newly selected time. How can I access the established “Clock” object from my main class?

First I thought I could make the clock be its own class and instantiate an object of that class from the main class and the settings class, however I think that leaves me with two timers active which is not what I want. Could I pass the Clock object from the main class to the settings class? What is the best route to take here?

EDIT:
My main form creates the Timer

Timer Clock = new Timer();

Then I establish the time each timer cycle should be, and start the timer.

public void MakeTheClockTimer()
{
Clock.Interval = formSettings.GetTimeInTicks();
Clock.Tick += new EventHandler(TimerEventProcessor);
Clock.Start();
}

My second form is referenced as “formSettings”. This form contains a combobox containing different time selections such as 1 minute, 15 minutes etc. When the program starts it performs the following start up:

   public Form1()
    {            
        InitializeComponent();
        MakeTheClockTimer();
     }

So the program starts, and looks at the settings form, returns what time is selected, and starts the timer. What I want to do is if the user chooses a different time, I want the program to basically call the “MakeTheClockTimer()” again. I need it to restart the timer if the time selection has changed. So something like:

private void cbxTime_SelectedIndexChanged(object sender, EventArgs e)
    {
        MainFormObject.MakeTheClockTimer();
    }

This would make it so that when the combobox was changed, it would re-establish the timers settings and start the timer again based on those settings.

  • 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-27T18:18:03+00:00Added an answer on May 27, 2026 at 6:18 pm

    Could I pass the Clock object from the main class to the settings
    class?

    Yes, but you will not be passing the object, you will be passing a reference to the object.

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

Sidebar

Related Questions

I am looking for free/opensource php form email script/class. The main requirement is that
I have a project with a main MDI form. There is a child MDI
The scope of this is that we have three main projects. Some of the
Presently, we've got several main projects each in their own repository. We will have
I'm currently working on two projects simultaneously: My main project (built with maven) A
I have just branched our Common Business Layer projects from the main to a
I've got two projects in WPF and one project is the main one and
Our main solution is the development code: shared libraries, services, UI projects, etc. The
Most of our Eclipse projects have multiple source folders, for example: src/main/java src/test/java When
I have two WIN32 DLL projects in the solution, main.dll should call a function

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.