41 lines
896 B
C#
41 lines
896 B
C#
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<TEventArgs>
|
|
|
|
public event EventHandler<VideoEventArgs> 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 });
|
|
}
|
|
}
|
|
}
|