Free cookie consent management tool by TermsFeed Policy Generator

Opened 14 years ago

Closed 13 years ago

#959 closed enhancement (done)

Correct EventPattern in HL

Reported by: mkommend Owned by: mkommend
Priority: lowest Milestone: HeuristicLab 3.3.2
Component: General Version: 3.3.2
Keywords: Cc: abeham

Description (last modified by mkommend)

As recommended the standard pattern for firing events should be implemented as follows [0]:

public event EventHandler MyEvent;
protected virtual void OnMyEvent()
{
    EventHandler handler = MyEvent;
    if (handler != null) handler(this, EventArgs.Empty);
} 

After discussions with swagner this should be corrected in the trunk, especially reading the event handler into a local variable. The EventArgs as a method parameter are not essential, because this could be another source of error (e.g. allocating new EventArgs instead of using EventArgs.Empty) and are therefore created in the method.

[0] http://blogs.msdn.com/cburrows/archive/2010/03/30/events-get-a-little-overhaul-in-c-4-afterward-effective-events.aspx

Change History (9)

comment:1 Changed 14 years ago by swagner

  • Description modified (diff)
  • Priority changed from major to trivial

comment:2 Changed 14 years ago by mkommend

  • Description modified (diff)

comment:3 Changed 14 years ago by abeham

  • Cc abeham added

comment:4 Changed 13 years ago by swagner

  • Status changed from new to accepted

comment:5 Changed 13 years ago by swagner

Firing of events has been corrected in the context of the cloning refactoring (see ticket #922).

comment:6 Changed 13 years ago by swagner

  • Status changed from accepted to reviewing

comment:7 Changed 13 years ago by mkommend

  • Owner changed from swagner to mkommend
  • Status changed from reviewing to readytorelease

comment:8 Changed 13 years ago by abeham

  • Version changed from 3.3 to 3.3.1

comment:9 Changed 13 years ago by swagner

  • Resolution set to done
  • Status changed from readytorelease to closed
  • Version changed from 3.3.1 to 3.3.2
Note: See TracTickets for help on using tickets.