Using Delegate Events in a Multi-Tenant Web Application

I am developing an n-tier multi-user web application using asp.net Mvc 5.

At my service level, I define custom events for each important action and raise these events after completing these actions. for instance

Public event EventHandler EntityCreated;

Public void Create(Entity item) {
  Save(item);
  ......
  EntityCreated(this, item);
}

I intend to connect business rules and notifications to these events. The main reason I want to use events is the decoupling of the logic and the ease of connecting additional event handlers without changing my level of service.

Question: Does it make sense to use events and delegates in asp.net?

Most of the examples that I find on the Internet are for win forms or wpf. I get an edge when it comes to multithreaded applications. Events are also defined once in the form and are active for the form's lifetime.

But in my case, the events will be behind the HTTP request . So is this the overhead defining these events?

+2
source share
2 answers

I implemented the Udi Dahan implementation as @Imran pointed out, but with a few changes.

My events are rising at the service level, and for this, using the Static Class effect seems to be correct. Also added support for async / wait.

"" "", , , .

http://www.teknorix.com/event-driven-programming-in-asp-net

0

, /sub - . - , , .

. , . db, , . , CustomerCreated. Domain Event, , ..

CustomerCreated , - , . EventHandlerService, ( ) , "Udi Dahan" . Udi DI, , SRP. , .

, , , .

+2

All Articles