05-26-2020 10:45 AM
Solved! Go to Solution.
06-01-2020 12:46 PM
I don't understand one thing: if your instrument is not on then exception should be thrown way before you are allowed to call EndReadString, when sending the command or when calling BeginRead. To make sure you don't call EndReadString prematurely you should always call it from the callback (AsyncCallback parameter) given to BeginRead. Having said that I also had problems and found this implementation of asynchronous IO a bit awkward, a more straightforward way to achieve asynchronous reading is to use normal blocking calls issued from a background thread (actually this is what I'm doing, you will find my gpib code on CodeProject), this works well and I can more easily know what the reason of an exception is.
06-02-2020 01:55 PM
Thanks. We have done similarly, using the normal blocking calls from within a Task, which seems to have fixed all of the asynchronous issues we were having.