Пример #1
0
        public static Task <int> WriteAsync(this UVFile file, Loop loop, Encoding encoding, string text, int offset)
        {
            var tcs = new TaskCompletionSource <int>();

            try {
                file.Write(loop, encoding, text, (e, result) => {
                    if (e == null)
                    {
                        tcs.SetResult(result);
                    }
                    else
                    {
                        tcs.SetException(e);
                    }
                }, offset);
            } catch (Exception e) {
                tcs.SetException(e);
            }
            return(tcs.Task);
        }
Пример #2
0
        public static Task <int> WriteAsync(this UVFile file, Loop loop, byte[] data, int index, int count, int offset)
        {
            var tcs = new TaskCompletionSource <int>();

            try {
                file.Write(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);
        }