using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace VideoEnc { public class VideoEventArgs : EventArgs { public Video Video { get; set; } } public class VideoEncoder { // 1- Define a delegate // 2- Define an Event // 3 Raise the event //EventHandler //EventHandler public event EventHandler VideoEncoded; public void Encode(Video video) { Console.WriteLine("Encoding video..."); Thread.Sleep(3000); OnVideoEncoded(video); } protected virtual void OnVideoEncoded(Video video) { if (VideoEncoded != null) VideoEncoded(this, new VideoEventArgs() { Video =video }); } } }