public static Task <int> ReadAsync(this UVFile file, Loop loop, byte[] data, int index, int count, int offset) { var tcs = new TaskCompletionSource <int>(); try { file.Read(loop, data, index, count, (e, result) => { if (e == null) { tcs.SetResult(result); } else { tcs.SetException(e); } }, offset); } catch (Exception e) { tcs.SetException(e); } return(tcs.Task); }