My USB device is communicating with my C# application once in 500ms and exchanging data(Using a timer and interrupt transfer.) So far seems Ok.
If my device is abruptly removed,(I think)windows 'device removal' message arrives only after removal is complete. But my application tries to write to my device in the meantime and throws an exception . safefilehandle closed
my FileIo.WriteFile failed.
at this time the writehandle is invalid and I closed it. WriteHandle.close
I tried by stopping next transfers but still exception throws with some other message.
The exception is sometimes thrown in some later try catch blocks. is it possible or my mistake in understanding ?
If a USB 'device write' failed as writehandle is no longer valid or present how should we tackle the exception and save the application from crashing?