Last active
August 15, 2018 01:01
-
-
Save lauromoura/6c80174a42e59fd5aeb367c1a67d6560 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class CustomEvent | |
{ | |
object eventLock = new Object(); | |
public event EventHandler CustomEvt | |
{ | |
add | |
{ | |
lock (eventLock) | |
{ | |
Console.WriteLine("Add called"); | |
CustomEvt += value; | |
} | |
} | |
remove | |
{ | |
lock (eventLock) | |
{ | |
Console.WriteLine("Remove vcalled"); | |
CustomEvt -= value; | |
} | |
} | |
} | |
public event EventHandler PlainEvt; | |
public void OnCustomEvt(EventArgs e) | |
{ | |
// Breaks with error CS0079: The event "CustomEvent.ChangedEvt" can only appear on the left hand side of "+=" or "-=" operator | |
CustomEvt(this, e); | |
} | |
public void OnPlainEvt(EventArgs e) | |
{ | |
PlainEvt(this, e); | |
} | |
public static void Main() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment