public void PreloadSamples(StreamType channelType, ushort channelNumber, IList <short> samples) { ITCMM.ITCChannelDataEx[] channelData = new ITCMM.ITCChannelDataEx[1]; channelData[0].ChannelType = (ushort)channelType; channelData[0].ChannelNumber = channelNumber; channelData[0].Value = (short)samples.Count; channelData[0].Command = ITCMM.PRELOAD_FIFO_COMMAND_EX; IntPtr samplesPtr = Marshal.AllocHGlobal(samples.Count * sizeof(short)); try { Marshal.Copy(samples.ToArray(), 0, samplesPtr, samples.Count); channelData[0].DataPointer = samplesPtr; uint err = ItcmmCall(() => ITCMM.ITC_ReadWriteFIFO(DevicePtr, 1, channelData)); if (err != ITCMM.ACQ_SUCCESS) { throw new HekaDAQException("Unable to push data", err); } } finally { Marshal.FreeHGlobal(samplesPtr); } }