private void NotifyFreeChannelsChanged() //1.
{
if (FreeChannelsChanged != null)
{
FreeChannelsChanged(this, null);
}
}
private void NotifyFreeChannelsChanged() //2.
{
NotifyCollectionChangedEventHandler h = FreeChannelsChanged ;
if (h != null)
h(this, e);
}
これより優れている理由は何ですか。それはちょっとしたチェックです。大きな違いはありません。イベントデリゲートを呼び出す方がよいでしょうか?
http://stackoverflow.com/questions/3668953/raise-event-thread-safely-best-practice?rq=1 –
オプション#2は、暗黙的に型指定された変数を使用します。私はパフォーマンスが問題ではないときにそれを気にしないでください。可読性と保守性を優先します。 – jay