L'opérateur ?.
qui peut être utilisé pour appeler un délégué ou un événement évite-t-il les conditions de concurrence?Évitez les conditions de course. opérateur
Par exemple. éviter condition de course manuellement:
//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);
}
}
source: msdn
Oui. https://codeblog.jonskeet.uk/2015/01/30/clean-event-handlers-invocation-with-c-6/ – vcsjones