Esempio n. 1
0
        /// <summary>
        /// Synchronous bulk/interrupt transfer function.
        /// </summary>
        /// <param name="buffer">A caller-allocated buffer for the transfer data. This object is pinned using <see cref="PinnedHandle"/>.</param>
        /// <param name="offset">Position in buffer that transferring begins.</param>
        /// <param name="length">Number of bytes, starting from thr offset parameter to transfer.</param>
        /// <param name="timeout">Maximum time to wait for the transfer to complete.</param>
        /// <param name="transferLength">Number of bytes actually transferred.</param>
        /// <returns>True on success.</returns>
        public ErrorCode Transfer(object buffer, int offset, int length, int timeout, out int transferLength)
        {
            PinnedHandle pinned  = new PinnedHandle(buffer);
            ErrorCode    eReturn = Transfer(pinned.Handle, offset, length, timeout, out transferLength);

            pinned.Dispose();
            return(eReturn);
        }
Esempio n. 2
0
 /// <summary>
 /// Fills the transfer with the data to <see cref="Submit"/> an isochronous transfer.
 /// </summary>
 /// <param name="buffer">The buffer; See <see cref="PinnedHandle"/> for more details.</param>
 /// <param name="offset">The offset on the buffer where the transfer should read/write.</param>
 /// <param name="count">The number of bytes to transfer.</param>
 /// <param name="timeout">Time (milliseconds) to wait before the transfer times out.</param>
 /// <param name="isoPacketSize">Size of each isochronous packet.</param>
 public virtual void Fill(object buffer, int offset, int count, int timeout, int isoPacketSize)
 {
     if (mPinnedHandle != null)
     {
         mPinnedHandle.Dispose();
     }
     mPinnedHandle = new PinnedHandle(buffer);
     Fill(mPinnedHandle.Handle, offset, count, timeout, isoPacketSize);
 }
Esempio n. 3
0
        /// <summary>
        /// Cancels any pending transfer and frees resources.
        /// </summary>
        public virtual void Dispose()
        {
            if (!IsCancelled)
            {
                Cancel();
            }

            int dummy;

            if (!mHasWaitBeenCalled)
            {
                Wait(out dummy);
            }
            if (mPinnedHandle != null)
            {
                mPinnedHandle.Dispose();
            }
            mPinnedHandle = null;
        }