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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:45:00+00:00 2026-06-09T10:45:00+00:00

I’m reading and reading, but I still can’t get the point and how to

  • 0

I’m reading and reading, but I still can’t get the point and how to use delegates/events and publisher/subscribers? I know that a delegate is a class that contains references to one or more methods and that it’s used to send methods to another methods.

The thing I don’t get is how I should determine the role of publischer/suubscriber. Let’s take an example. A taxicentral and it’s cabs. Is the taxicentral the publischer and the cabs the subscribers, whating to get driving orders from the taxicentral? But the cabs could also be publisher and report back there position and the address they are heading for to the taxicentral that, then is a subscriber of the cabs!?

I need inspiration and I’m looking for som beginners code to get a view of how this is working. Is there someone who have some minutes left to reply to this answer with some simple code? Thanks!

  • 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-09T10:45:01+00:00Added an answer on June 9, 2026 at 10:45 am

    Another way to think of events, publishers/subscribers, etc…is to think of the cloud and the way it tends to function. In a cloud based system, any entity can register to listen for any type of event, OR can publish any event that it wants. Anyone listening, will get that data.

    In your example: Taxi central could publish/push events like Shift Change, Traffic Accident as (Location), Taxi Requested at (Location), or other similar things that the entire group of cabs would be listening for. The individual cabs would be publishing things like Pickup At (Location), Drop Off at (Location), Accident at (Location); that Central would be logging for its own purposes. Other cabs could if they wanted to ALSO be listening for these same events, so that they would know where and how close other cabs are to their own location, or if there is an accident that another cab reported, or similar.

    Cloud events however are a specific implementation of the event system. Its much more common to specifically subscribe to events. A cab object, when created, would immediately subscribe itself to the Central events, and the central system when dispatching the cab would make certain that it subscribed itself to that cab’s events.

    In this way, both objects serve the role of both publisher and subscriber. Its only really specific to a single event. In my example PickupAt(Location) would be published by a Cab, and Subscribed to by Central. Thus, for that event, Cab is the publisher, and Central is the Subscriber. In general, Who serves what role depends entirely on the system design and what events are being created. Its not something that can really be generalized, because the entire setup could be changed, or even reversed, if you setup the events differently. That I think is the most important part.

    Delegates as a whole

    In its simplest term, a Delegate is a Reference. It can reference a class, more commonly it can reference a method in a class, or the call to a method in a class. It can even contain an entire method call inside itself. Its really a very versatile object, in that it can do many things. In the context of events, the delegate actually references the call to the function that implements the event.

    Simple Event Code

    public class c1
    {
        public event Eventhandler DoStuff;
    
        public c1()
        {
    
        }
    
        public void OnDoStuff()
        {//this actually makes the event happen
            if (DoStuff != null)
                DoStuff(this, null);
        }
    }
    
    public static void Main()
    {
        c1 x = new c1();
        x.DoStuff += new EventHandler(ThingFunction);
    
        x.OnDoStuff();//this is how you would fire the event deliberately
    }
    
    public void ThingFunction(object sender, EventArgs x)
    {
        Console.WriteLine("Something Happened");
    }
    

    c1 contains the event DoStuff, Main subscribes to this event. When the code calls x.OnDoStuff() from ANYWHERE, which is very handy if say you pass x, or a reference to it, into other classes where actual code is processed, then the handler way back in main, no matter how many layers deep the x.OnDoStuff() call originates from, will execute.

    Rather more specifically, once X is created, it can be passed somewhere else. As long as some function is assigned to x.DoStuff, whenever and wherever you call the method x.OnDoStuff() from, the function that is assigned to x.DoStuff will execute. That is how event subscriptions work. x.OnDoStuff() is the code call that publishes the event x.DoStuff, and any class…in fact any number of classes, you can have multiple subscribers after all, will be able to catch the published event.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't

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.