public bool OnEvent(BaseEvent ev) { var canMessageEvent = (CanMessageEvent)ev; CanController device = null; lock (_canControllersMap) { device = FindCanController(canMessageEvent.ControllerIndex); } // Avoid calling this under a lock to prevent a potential lock inversion. if (device != null) { device.OnCanMessageReceivedInternal(canMessageEvent.Event); } else { return(false); } return(true); }