public void OnNewColour(ColourEventArgs colourArgs) { // Note the copy to a local variable, so that we don't risk a // NullReferenceException if another thread unsubscribes between the test and // the invocation. ColourEventHandler handler = NewColour; if (handler != null) { handler(this, colourArgs); } }
private void UpdateColour(Color colour) { this.SelectedColour = colour; ColourEventArgs args = new ColourEventArgs(colour); OnNewColour(args); this.Refresh(); }