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; }
public void RequestTimeout (ref IOUSBDevRequestTO request) { ThrowIfDisposed (); var result = Interface.DeviceRequestTO (InterfaceRef, ref request); IOObject.ThrowIfError (result); }