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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:48:27+00:00 2026-05-22T19:48:27+00:00

In my last job interview I was asked how to implement a class which

  • 0

In my last job interview I was asked how to implement a class which exposes an event and notifies new event subscribers at the moment they subscribe to that event.

In other words, a class exposes an event to inform subscribers when a data source is updated; many other classes can subscribe to the event at any point in time. When a class subscribes to the event it must be notified to get latest version of data stored into the data source, but other classes must not be notified (they are already up to date).

They have suggested me to override the addHandler method, but how do I notify only the new subscriber?

Is there a feature of the .net I’m not aware of or do I need to define a method in the subscriber class to be called when adding to handler (some kind observer pattern)?

EDIT: i think i’m not been clear, so i’ll try to explain it in another way.
Suppose i’ve an observer pattern. When a new observer subscribe the subject it gets immediatly updated with lastest datasource values by subject .Later, when somethnig inside the datasource will change, the subject will notify all registered observers as usual. I’m been asked how to make this with .net events

  • 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-22T19:48:28+00:00Added an answer on May 22, 2026 at 7:48 pm

    Your terminology is wooly – what do you mean by “it must be activated”? Do you mean the event handler has to be called once at the point of subscription? If so, that sounds something like:

    private EventHandler foo;
    
    public event EventHandler Foo 
    {
        add
        {
            if (value != null)
            {
                value(this, EventArgs.Empty);
            }
            foo += value;
        }
    
        remove
        {
            foo -= value;
        }
    }
    

    It’s a pretty odd design though.

    If that isn’t what you’re after, please try to clarify.

    See my article on events and delegates for more information.

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

Sidebar

Related Questions

I went to a PHP job interview, I was asked to implement a piece
In my last job we ended up rewriting the complete ASP.NET stack (forms, controls,
In my last job, we worked on a very database-heavy application, and I developed
Since I didn't do a good job writing the last question, and most of
last time I asked how to populate a data structure here . Now I
Last time I asked about the reverse process , and got some very efficient
I just started a new job yesterday and this is only my second job
I was on a technical job interview today, and it was time to give
I recently started at a new job where I'll be working with Sharepoint 2010
I'm in a situation where I came into a new job and I have

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.