델리게이트 또는 이벤트를 호출하는 데 사용할 수있는 ?.
연산자가 경쟁 조건을 피할 수 있습니까?경쟁 조건을 피하십시오? operator
예 : 수동으로 경쟁 조건을 피하기 :
//The event-invoking method that derived classes can override.
protected virtual void OnShapeChanged(ShapeEventArgs e)
{
// Make a temporary copy of the event to avoid possibility of
// a race condition if the last subscriber unsubscribes
// immediately after the null check and before the event is raised.
EventHandler<ShapeEventArgs> handler = ShapeChanged;
if (handler != null)
{
handler(this, e);
}
}
소스 : msdn
예를 평가 스레드 안전합니다. https://codeblog.jonskeet.uk/2015/01/30/clean-event-handlers-invocation-with-c-6/ – vcsjones