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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:24:27+00:00 2026-06-16T07:24:27+00:00

I am stuck on coming up with a clean design for my problem (below).

  • 0

I am stuck on coming up with a clean design for my problem (below). I have contemplated a pub/sub or observer pattern, but my problem seems opposite of these approaches unless I am just not thinking correctly. Maybe the Mediator pattern will work, but it still doesnt quite seem right to me for some reason. So, any help in what design is needed here, please let me know 🙂

My problem is that I need a handler that can handle events from multiple sources. I need a hotkey manager that can manage events from multiple places. IE. If a keypress is encountered, then some action should happen. Or, if a button is pressed on a microphone (different source), then an action should happen.

My current idea is to implement the manager as a singleton (not a huge fan of this…), and have classes register in the manager. The classes would need to implement an interface that would guarantee a certain event that the manager would attach to (when they were registered). I just don’t like this because the class would need to raise this event, which is not something that is guaranteed by the contract per se

  • 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-16T07:24:28+00:00Added an answer on June 16, 2026 at 7:24 am

    Your current idea sounds fine, but I would make the following tweaks:

    • no need for the manager to be a singleton;

    • the event sources do not need to register themselves with the hotkey manager, some other class (a builder) could be responsible for registering them with the manager, this removes the dependency from the sources on the manager.

    E.g.

    public class HotKeyManager
    {
        public void RegisterKeySource(IKeySource source)
        {
            source.OnKeyPress += this.KeyPressHandler;
        }
    
        public void KeyPressHandler(object sender, KeyPressEventArgs args)
        {
            // ...
        }
    
        // ...
    }
    
    public interface IKeySource
    {
        event EventHandler<KeyPressEventArgs> OnKeyPress;
    
        // ...
    }
    

    Some other class handles the source registration:

    var hotKeyManager = new HotKeyManager();
    
    var keySource = new MyKeySource(); // Implements IKeySource
    
    hotKeyManager.RegisterKeySource(keySource);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im stuck with this little project in C# but basically my problem is this:
I'm a bit stuck here with a simple question: I have objects (coming via
Im stuck again. Its very frustrating coming from a ruby background. I have 3
I'm stuck. Coming from C++ I thought this would simply work, but it does
I have an exam coming up in the near future and I'm really stuck
I am stuck with a strange problem that, I have a image view which
Kinda stuck here... I have an application with lets say 5000 rows of data
I stuck with problem of mail application , i am developing a website for
im stuck with a problem im basically trying to create a function where I
I am using jQuery validator plugin, i stuck in a problem during validating images,

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.