Switched to .NET event handlers

Switched to .NET event handlers so that event handlers block the core while running. Matlab's listeners don't block and instead go into the event queue which is easily inadvertently flushed by protocols.