This project is read-only.

Basic Events

Aim of the project

This projects generates a library that contains events, their event_args and methods to fire these events.

Sample business library dll file and console application is provided for demo purpose.

Libraries and executable files provided

  • basicevents.dll: library contains events, event_args and controller class that have the methods to fire the events.
  • dmo_bll.dll: demo business tier project that fire basic events.
  • dmo_exe.exe: demo presentation tier application that handles the basic events fired by the business tier project.

Current Events

  • MessageReceived: its EventArgs contains a message property of string type.
  • TimeMessageReceived: its EventArgs contains a Message property of string data type and a Time property of DateTime type.
  • ExceptionReceived: its EventArgs contains an Error property of Exception type.

How to use

In your class that you wish to fire the event

Declare private or protected attribute of Events class.

private BasicEvents.Events _events = new BasicEvents.Events();

Declare a public read only property to return the Events class instance that all the events will be fired from.

public BasicEvents.Events Events

{

get

{

return _events;

}

}

Where you want to fire one of the basic events just call the related method:

_events.FireMessageReceived(this, "Demo");

Fire events methods:

  • FireMessageReceived: fires MessageReceived event.
  • FireTimeMessageReceived: fires TimeMessageReceived event.
  • FireExceptionReceived: fires ExceptionReceived event.

In your presentation tier, or the class where you intend to handle the events fired:

Provided that you make instance of the business tier library

DMO_BLL.DMO _dmo = new DMO_BLL.DMO();

Register the event handlers

_dmo.Events.MessageReceived += new BasicEvents.Events.MessageReception(Events_MessageReceived);

Create the Events_MessageReceived method

void Events_MessageReceived(object sender, BasicEvents.MessageEventArgs e)

{

Console.WriteLine(e.Message);

}

Run the business method in the business tier library

_dmo.DemoMethod();

Last edited Jan 23, 2011 at 9:18 PM by gnairooze, version 1

Comments

No comments yet.