Global static error event for all Usb errors.

C# | Visual Basic | Visual C++ |
public static event EventHandler<UsbError> UsbErrorEvent
Public Shared Event UsbErrorEvent As EventHandler(Of UsbError)
public: static event EventHandler<UsbError^>^ UsbErrorEvent { void add (EventHandler<UsbError^>^ value); void remove (EventHandler<UsbError^>^ value); }

Sample code to reset an endpoint if a critical error occurs.
CopyC#

// Hook the usb error handler function UsbGlobals.UsbErrorEvent += UsbErrorEvent; private void UsbErrorEvent(object sender, UsbError e) { // If the error is from a usb endpoint if (sender is UsbEndpointBase) { // If the endpoint transfer failed if (e.Win32ErrorNumber == 31) { // If the USB device is still open, connected, and valid if (usb.IsOpen) { // Try to reset then endpoint if (((UsbEndpointBase) sender).Reset()) { // Endpoint reset successful. // Tell LibUsbDotNet to ignore this error and continue. e.Handled = true; } } } } }