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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:17:21+00:00 2026-06-03T15:17:21+00:00

Not sure how noob or advanced this question is, but I’ve been having kind

  • 0

Not sure how noob or advanced this question is, but I’ve been having kind of trouble finding a good answer so thought I give it a try here.

To describe my question in words is the following. I have a program that Init’s a “engine” at startup that is the source for all data and information for this program. The thing is right now if I write a new class right now I have to include it when the class is created.

public class ClassName(TMEngine engine)
{
......
}

What I wonder is if how I could use a “child : parent” class relation to have this on the parent so the only this I have to know is what its called.
I have written classes both for the Form and UserControl to have some extras in them so there is a parent class.

public partial class msgCtrlContainerCtrl : TMUserControl
{
     public msgCtrlContainerCtrl(TMEngine engine)
     {
        ......
     }
}

As this is a WinForms application I init the engine in the form, but would like all controls created in it used the same engine.

Setting up the engine on “Load-event” in the TMUserControl does not work right now as the UserControl will be initialized on “add” as a UserControl, and the Load event will be run much further behind this.

And you can not look for a parent to the control as the parent-relation has not been initialized yet when you do the “add” for a new control.

So any ideas how to solve this in the best way to place this engine in sync in my extended UserControl class I call TMUserControl here or dose it have to be in every class that uses 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-06-03T15:17:23+00:00Added an answer on June 3, 2026 at 3:17 pm

    Are you looking for something like this?

    public class TMEngine
    {
       private TMEngine() {}
    
       private static TMEngine instance;    
       public static TMEngine Instance
       {
          get 
          {
             if (instance == null)             
                instance = new TMEngine();             
             return instance;
          }
       }
    
       public string GetSomeStringData()
       {
           ...
       }
    }
    

    This will be your engine… so you can go ahead and construct the way you want.
    Now you need an abstract for all your classes that will use the engine.

    public abstract class EnginedClass
    {
        public static TMEngine Engine { get { return TMEngine.Instance; } };
    }
    

    Then just implement your classes using it:

    public MyNewClass : EnginedClass
    {
        ...
        public string GetSomeData()
        {
            ...
            return Engine.GetSomeStringData();
        }
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty sure that this question is very noob but I'm not used to
Im an iphone noob. I'm not sure if I'm asking this correctly, but I
Not sure if I've just missed something but this doesn't work: $(this).children('td.threadtitle a').html('thread title');
Not sure how to ask this as I'm a bit of a database noob,
Hi I'm sure this is possible but am not sure how to go about
This is probably a noob question that I will get slated for but here
I am new to drupal, so sorry for this noob question, but I was
Apologies for this basic question, but I am noob stumped. The below code works
Question: Hello All, Sorry that this is kind of a noob question. I just
This might be a noob question, but I'm wondering if there's a way to

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.