61
1
using System;
2
3
public class Program
4
{
5
public static void Main()
6
{
7
ProcessBusinessLogic bl = new ProcessBusinessLogic();
8
bl.ProcessCompleted += bl_ProcessCompleted; // register with an event
9
bl.StartProcess();
10
}
11
12
// event handler
13
public static void bl_ProcessCompleted(object sender, ProcessEventArgs e)
14
{
15
Console.WriteLine("Process " + (e.IsSuccessful? "Completed Successfully": "failed"));
16
Console.WriteLine("Completion Time: " + e.CompletionTime.ToLongDateString());
17
}
18
}
19
20
public class ProcessEventArgs : EventArgs
21
{
22
public bool IsSuccessful { get; set; }
23
public DateTime CompletionTime { get; set; }
24
Cached Result