Help me please to implement an event, which handler can cancel it.
public class BuildStartEventArgs : EventArgs
{
public bool Cancel { get; set; }
}
class Foo
{
public event EventHandler<BuildStartEventArgs> BuildStart;
private void Bar()
{
// build started
OnBuildStart(new BuildStartEventArgs());
// how to catch cancellation?
}
private void OnBuildStart(BuildStartEventArgs e)
{
if (this.BuildStart != null)
{
this.BuildStart(this, e);
}
}
}