| Using VISA.NET > Raw I/O > Asynchronous I/O |
VISA.NET Raw I/O includes methods for asynchronous operations. By using these methods, a calling program can do other tasks while waiting for I/O to complete, and can queue multiple I/O operations so that sequences of I/O operations execute as quickly as possible.
Raw I/O includes methods that begin write and read operations, then return without waiting to see if the operations have completed. You can use any of several techniques to check the status of an I/O operation, and to get the results when the I/O operation is complete.
In theory, VISA.NET asynchronous I/O is asynchronous with regard to a .NET application domain, but in fact Keysight VISA.NET delegates its functionality to the unmanaged Keysight VISA C implementation, which is asynchronous with regard to a process.
Asynchronous I/O is not asynchronous with respect to a resource, at least within the process of a calling program. I/O operations are generally processed in the order in which they are initiated, so that reads and writes happen in a predictable order.
Asynchronous I/O starts with a call to a BeginWrite or BeginRead method. These methods return a reference to the IVisaAsyncResult interface. This interface includes information that uniquely identifies the operation and can be used to communicate status and results.
You can abort asynchronous I/O by calling AbortAsyncOperation. This method takes an IVisaAsyncResult argument, which identifies the particular asynchronous I/O operation to abort.
Asynchronous I/O operations are formally completed when the program calls EndWrite, EndRead, or EndReadString. These methods also take an IVisaAsyncResult argument, which identifies the particular asynchronous I/O operation to end.
![]() |
You must call the appropriate End method after any Begin method is called and returns a valid reference to IVisaAsyncResult. End methods perform required clean-up and disposal functions, and if you do not call the End method, you will create memory leaks. Even if you have called AbortAsyncOperation, you must still call an End method. |
VISA.NET Asynchronous I/O uses the IVisaAsyncResult interface to identify particular asynchronous I/O operations, and to communicate status and results. IVisaAsyncResult derives from the .NET Framework class System.IAsyncResult.
IVisaAsyncResult includes the following useful properties:
For complete details, refer to the reference documentation for IVisaAsyncResult.
There are three patterns you can use to determine when an asynchronous operation is complete: polling, blocking waits, and callbacks. These three samples, taken together, illustrate the fundamental design choices behind good asynchronous VISA.NET programs: