Beispiel #1
0
        public void RequestTimeout(ref IOUSBDevRequestTO request)
        {
            ThrowIfDisposed();
            var result = Interface.DeviceRequestTO(InterfaceRef, ref request);

            IOObject.ThrowIfError(result);
        }
Beispiel #2
0
        public Task <int> RequestTimeoutAsync(IOUSBDevRequestTO request)
        {
            ThrowIfDisposed();
            var              completionSource = new TaskCompletionSource <int> ();
            GCHandle         callbackHandle   = new GCHandle();
            IOAsyncCallback1 callback         = (refCon, callbackResult, arg0) => {
                callbackHandle.Free();
                if (callbackResult == IOReturn.Success)
                {
                    completionSource.TrySetResult((int)arg0);
                }
                else
                {
                    completionSource.TrySetException(callbackResult.ToNSErrorException());
                }
            };

            callbackHandle = GCHandle.Alloc(callback, GCHandleType.Pinned);
            var result = Interface.DeviceRequestAsyncTO(InterfaceRef, request, callback, IntPtr.Zero);

            IOObject.ThrowIfError(result);
            return(completionSource.Task);
        }