Solved

c# event : publish and subscribe

Posted on 2014-02-14
4
55 Views
Last Modified: 2016-06-16
I am trying to setup event in the server side, so when request coming, i register an event, and from other places i can subscribe to this event, say certain properties change, i want to raise or execute the event. Is it something possible in asp.net (c#)?  So similar to what JS has, publish an event, and subscribe from diff places.
0
Comment
Question by:johndenny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 39860137
Yes you can.

Essentially you can create a class that inherits from a standard control.  

public class MyUserControl : UserControl
{
   //this allows you to "publish" the event
    public delegate void onMyEvent(int AParam);
    public event onMyEvent MyEvent;
 
    public MyUserControl()
    {
          //subscribe to the event
          MyEvent += MyEventHandler;
    }

   // this occurs when the event happens
    public void MyEventHandler(int Param)
    {
                // do something
    }

}
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 41655414
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Universal App 22 55
Timeouts during development 3 26
Disable the weekends on datepicker control 6 50
UWP: Create an Image/Bitmap, Draw another image on it an save. 1 39
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question