BeginMemoryOptimizedReadMultiSamplePortByte(int, AsyncCallback, object, byte)
- Updated2026-02-05
- 2 minute(s) read
Begins an asynchronous read of one or more 8-bit unsigned integer samples from one or more DIChannel objects in a task.
Syntax
Namespace: NationalInstruments.DAQmx
public IAsyncResult BeginMemoryOptimizedReadMultiSamplePortByte(int samplesPerChannel, AsyncCallback callback, object state, byte[,] data)
Remarks
If the data buffer is large enough to hold the number of samples requested, this overload attempts to reuse existing memory allocated from the array to acquire data. This results in more efficient memory allocation when performing multiple reads with a continuous digital input task.
To get the read data or any exceptions that occurred during an asynchronous read initiated with this method, call EndMemoryOptimizedReadMultiSamplePortByte(IAsyncResult, out int) with the returned IAsyncResult.
NI-DAQmx scales the returned data to the units of the measurement, including any custom scaling you apply to the channel. You specify these units with the create channel methods or the DAQ Assistant.
NI-DAQmx read and write methods time out after the amount of time specified by the Timeout property on the task you are reading from or writing to.
Refer to NI-DAQmx Readers and Writers for more information about memory limitations in NI-DAQmx read methods.
Refer to Asynchronous Reads and Writes for additional information.
Asynchronous Reads and Writes
Parameters
| Name | Type | Description |
|---|---|---|
| samplesPerChannel | int | The number of samples to read. If you set samplesPerChannel to -1 for a continuous acquisition, the read retrieves all samples available in the buffer at the time of the read. If you set samplesPerChannel to -1 for a finite acquisition, the read behavior is set by the ReadAllAvailableSamples property of the DaqStream you are reading from. |
| callback | AsyncCallback | An optional asynchronous callback that is called when the read is complete. Specify null if you do not want a callback when the read is complete. |
| state | object | A user-provided object that distinguishes this asynchronous read request from other requests. Use this parameter to provide information to the callback. Specify null if you do not need to pass any additional information to the callback. |
| data | byte | An initialized 2D array of 8-bit unsigned integer samples that contains the read data. Each element in the first dimension of the array corresponds to a channel in the task. Each element in the second dimension of the array corresponds to a sample from each of the channels. The order of the channels in the array corresponds to the order in which you add the channels to the task or to the order of the channels you specify in ChannelsToRead. |
Returns
An IAsyncResult that represents the asynchronous call.