I am going through this code below:
public delegate void PersonArrivedEventHandler(string personName, byte[] personId);
public class SCLib
{
public event personArrivedEventHandler personrrived;
public SCLib()
{
// Simulate that the person arrived after 2000 milli-seconds.
Task.Run(() =>
{
System.Threading.Thread.Sleep(2000);
OnPersonArrived("personName", new byte[] { 0x20, 0x21, 0x22 });
});
}
protected virtual void OnPersonArrived(string smartCardReaderName, byte[] smartCardId)
{
if (this.personArrived != null)
{
PersonArrived(personName, personId);
}
}
}
But, I don't know what is the significance of this line,
if (this.personArrived != null)
.
Why is this check done here? Is there any significance of the if statement
here? I removed this line and ran the program and everything works as before.
Thanks.