void RaiseNewData(object context) { WinUSBDevice.NewDataCallback cb = NewDataEvent; if (cb != null) { long dataMarker = -1; while (dataMarker != TotalReceivedBytes) { dataMarker = TotalReceivedBytes; cb(); } } }
void RaiseNewData(object context) { WinUSBDevice.NewDataCallback cb = NewDataEvent; if (cb != null) { if (EventConcurrency.WaitOne(0)) // Prevent requests from stacking up; Don't issue new events if there are several in flight { try { cb(); } finally { EventConcurrency.Release(); } } } }