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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:23:46+00:00 2026-05-17T01:23:46+00:00

I have a parent class that contains an array of objects each with a

  • 0

I have a parent class that contains an array of objects each with a timer associated with it.

I want the parent class to be able to start and stop these timers, and most importantly want the parent class to detect which of the it’s child objects ‘timer elapsed’ even has been raised.

Is this possible and if so what is the best way to do it?

  • 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-17T01:23:47+00:00Added an answer on May 17, 2026 at 1:23 am

    I would suggest that you give the child objects an event that can be raised when the Timer is fired. Then the Parent class can attach a handler to the event from each child.

    Here is some pseudo code to give you an idea of what I mean. I have purposely not shown any WinForms or Threading code, because you do not give much detail in that area.

    class Parent
    {
      List<Child> _children = new List<Child>();
    
      public Parent()
      {
        _children.Add(new Child());
        _children.Add(new Child());
        _children.Add(new Child());
    
        // Add handler to the child event
        foreach (Child child in _children)
        {
          child.TimerFired += Child_TimerFired;
        }
      }
    
      private void Child_TimerFired(object sender, EventArgs e)
      {
        // One of the child timers fired
        // sender is a reference to the child that fired the event
      }
    }
    
    class Child
    {
      public event EventHandler TimerFired;
    
      protected void OnTimerFired(EventArgs e)
      {      
        if (TimerFired != null)
        {
          TimerFired(this, e);
        }
      }
    
      // This is the event that is fired by your current timer mechanism
      private void HandleTimerTick(...)
      {
        OnTimerFired(EventArgs.Empty);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that contains an IList<T> property called Children . Each child
I have a class that contains hierarchical data. I want to present this data
I have a parent and child class that both need to implement IDisposable .
I have a private method def __pickSide(self): in a parent class that I would
In Django, when you have a parent class and multiple child classes that inherit
I have a model that looks something like this: public abstract class Parent {
I have a parent class which contains a child object. I am using set
I have a Portlet that contains a form. Now what I want to achieve
I have an object model that contains a class with several subclasses. The subclasses
I have an object that contains a list of other objects. Say it's as

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.