当前位置: 首页>>代码示例>>C#>>正文


C# this.BeginWrite方法代码示例

本文整理汇总了C#中this.BeginWrite方法的典型用法代码示例。如果您正苦于以下问题:C# this.BeginWrite方法的具体用法?C# this.BeginWrite怎么用?C# this.BeginWrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


在下文中一共展示了this.BeginWrite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteAsync

        public static IObservable<Unit> WriteAsync(this Stream This, byte[] data, int start, int length)
        {
            var ret = new AsyncSubject<Unit>();

            try
            {
                This.BeginWrite(data, start, length, result =>
                {
                    try
                    {
                        This.EndWrite(result);
                        ret.OnNext(Unit.Default);
                        ret.OnCompleted();
                    }
                    catch (Exception ex)
                    {
                        ret.OnError(ex);
                    }
                }, null);
            }
            catch (Exception ex)
            {
                ret.OnError(ex);
            }

            return ret;
        }
开发者ID:jorik041,项目名称:Akavache,代码行数:27,代码来源:StreamMixins.cs

示例2: WriteAsync

        public static Task WriteAsync(this Stream stream, byte[] buffer, int offset, int count)
        {
            var tcs = new TaskCompletionSource<object>();
            var sr = stream.BeginWrite(buffer, offset, count, ar =>
            {
                if (ar.CompletedSynchronously)
                {
                    return;
                }
                try
                {
                    stream.EndWrite(ar);
                    tcs.SetResult(null);
                }
                catch (Exception ex)
                {
                    tcs.SetException(ex);
                }
            }, null);

            if (sr.CompletedSynchronously)
            {
                try
                {
                    stream.EndWrite(sr);
                    tcs.SetResult(null);
                }
                catch (Exception ex)
                {
                    tcs.SetException(ex);
                }
            }
            return tcs.Task;
        }
开发者ID:anurse,项目名称:gate,代码行数:34,代码来源:Net40Extensions.cs

示例3: BeginWrite

        /// <summary>
        /// Extends BeginWrite so that buffer offset of 0 and call to Array.Length are not needed.
        /// <example>
        /// sqlfilestream.BeginWrite(buffer, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginWrite(this SqlFileStream sqlfilestream, Byte[] buffer, AsyncCallback callback)
        {
            if(sqlfilestream == null) throw new ArgumentNullException("sqlfilestream");

            if(buffer == null) throw new ArgumentNullException("buffer");

            return sqlfilestream.BeginWrite(buffer, 0, buffer.Length, callback);
        }
开发者ID:peteraritchie,项目名称:ProductivityExtensions,代码行数:14,代码来源:SqlFileStreamable.g.cs

示例4: BeginWrite

        /// <summary>
        /// Extends BeginWrite so that buffer offset of 0 and call to Array.Length are not needed.
        /// <example>
        /// networkstream.BeginWrite(buffer, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginWrite(this NetworkStream networkstream, Byte[] buffer, AsyncCallback callback)
        {
            if(networkstream == null) throw new ArgumentNullException("networkstream");

            if(buffer == null) throw new ArgumentNullException("buffer");

            return networkstream.BeginWrite(buffer, 0, buffer.Length, callback);
        }
开发者ID:peteraritchie,项目名称:ProductivityExtensions,代码行数:14,代码来源:NetworkStreamable.g.cs

示例5: BeginWrite

        /// <summary>
        /// Extends BeginWrite so that buffer offset of 0 and call to Array.Length are not needed.
        /// <example>
        /// deflatestream.BeginWrite(array, asyncCallback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginWrite(this DeflateStream deflatestream, Byte[] array, AsyncCallback asyncCallback)
        {
            if(deflatestream == null) throw new ArgumentNullException("deflatestream");

            if(array == null) throw new ArgumentNullException("array");

            return deflatestream.BeginWrite(array, 0, array.Length, asyncCallback);
        }
开发者ID:peteraritchie,项目名称:ProductivityExtensions,代码行数:14,代码来源:DeflateStreamable.g.cs

示例6: BeginWrite

        /// <summary>
        /// Extends BeginWrite so that buffer offset of 0 and call to Array.Length are not needed.
        /// <example>
        /// isolatedstoragefilestream.BeginWrite(buffer, userCallback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginWrite(this IsolatedStorageFileStream isolatedstoragefilestream, Byte[] buffer, AsyncCallback userCallback)
        {
            if(isolatedstoragefilestream == null) throw new ArgumentNullException("isolatedstoragefilestream");

            if(buffer == null) throw new ArgumentNullException("buffer");

            return isolatedstoragefilestream.BeginWrite(buffer, 0, buffer.Length, userCallback);
        }
开发者ID:peteraritchie,项目名称:ProductivityExtensions,代码行数:14,代码来源:IsolatedStorageFileStreamable.g.cs

示例7: BeginWrite

        /// <summary>
        /// Extends BeginWrite so that buffer offset of 0 and call to Array.Length are not needed.
        /// <example>
        /// pipestream.BeginWrite(buffer, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginWrite(this AnonymousPipeClientStream pipestream, Byte[] buffer, AsyncCallback callback)
        {
            if(pipestream == null) throw new ArgumentNullException("pipestream");

            if(buffer == null) throw new ArgumentNullException("buffer");

            return pipestream.BeginWrite(buffer, 0, buffer.Length, callback);
        }
开发者ID:peteraritchie,项目名称:ProductivityExtensions,代码行数:14,代码来源:AnonymousPipeClientStreamable.g.cs

示例8: BeginWrite

        /// <summary>
        /// Extends BeginWrite so that buffer offset of 0 and call to Array.Length are not needed.
        /// <example>
        /// stream.BeginWrite(buffer, callback, state);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginWrite(this Stream stream, Byte[] buffer, AsyncCallback callback, Object state)
        {
            if(stream == null) throw new ArgumentNullException("stream");

            if(buffer == null) throw new ArgumentNullException("buffer");

            return stream.BeginWrite(buffer, 0, buffer.Length, callback, state);
        }
开发者ID:peteraritchie,项目名称:ProductivityExtensions,代码行数:14,代码来源:Streamable.g.cs

示例9: BeginWrite

        /// <summary>
        /// Extends BeginWrite so that buffer offset of 0 and call to Array.Length are not needed.
        /// <example>
        /// gzipstream.BeginWrite(array, asyncCallback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginWrite(this GZipStream gzipstream, Byte[] array, AsyncCallback asyncCallback)
        {
            if(gzipstream == null) throw new ArgumentNullException("gzipstream");

            if(array == null) throw new ArgumentNullException("array");

            return gzipstream.BeginWrite(array, 0, array.Length, asyncCallback);
        }
开发者ID:peteraritchie,项目名称:ProductivityExtensions,代码行数:14,代码来源:GZipStreamable.g.cs

示例10: WriteAsync

        /// <summary>
        /// <paramref name="buffer"/> 내용을 지정된 스트림에 비동기 방식으로 씁니다.
        /// </summary>
        public static Task WriteAsync(this Stream stream, byte[] buffer, int offset, int count) {
            if(IsDebugEnabled)
                log.Debug("버퍼의 내용을 비동기 방식으로 스트림에 씁니다... offset=[{0}], count=[{1}]", offset, count);

            // Silverlight용 TPL에서는 지원하지 3개 이상의 인자를 지원하지 않는다.
            var ar = stream.BeginWrite(buffer, offset, count, null, null);
            return Task.Factory.StartNew(() => stream.EndWrite(ar));
        }
开发者ID:debop,项目名称:NFramework,代码行数:11,代码来源:StreamAsync.cs

示例11: BeginWrite

        /// <summary>
        /// Extends BeginWrite so that buffer offset of 0 and call to Array.Length are not needed.
        /// <example>
        /// filestream.BeginWrite(array, userCallback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginWrite(this FileStream filestream, Byte[] array, AsyncCallback userCallback)
        {
            if(filestream == null) throw new ArgumentNullException("filestream");

            if(array == null) throw new ArgumentNullException("array");

            return filestream.BeginWrite(array, 0, array.Length, userCallback);
        }
开发者ID:peteraritchie,项目名称:ProductivityExtensions,代码行数:14,代码来源:FileStreamable.g.cs

示例12: BeginWrite

        /// <include file='../_Doc/mscorlib.xml' path='doc/members/member[@name="M:System.IO.Stream.BeginWrite(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object)"]/*' />
        /// <param name="stream">Stream on which to begin writing.</param>
        public static IAsyncResult BeginWrite(this Stream stream, byte[] buffer, int offset, int count,
                                              AsyncCallback callback, object state)
        {
#if DOTNET || WINDOWS_PHONE
            return stream.BeginWrite(buffer, offset, count, callback, state);
#else
            return
                new TaskFactory().StartNew(asyncState => stream.Write(buffer, offset, count), state)
                                 .ContinueWith(task => callback(task));
#endif
        }
开发者ID:BeeINSIGHT,项目名称:shim,代码行数:13,代码来源:StreamExtensions.cs

示例13: NioWrite

        public static IYield NioWrite(this Stream stream, byte[] buffer, int offset, int count)
        {
            var waitEvent = new WaitEvent();
            stream.BeginWrite(buffer, offset, count, ar =>
                                                         {
                                                             stream.EndWrite(ar);
                                                             ((WaitEvent) ar.AsyncState).Set();
                                                         }, waitEvent);

            return Microthread.Wait(waitEvent);
        }
开发者ID:shlee322,项目名称:Netronics,代码行数:11,代码来源:NioStream.cs

示例14: Write

        public static void Write(this Stream stream, byte[] buffer, int offset, int size, Action continuation)
        {
            var daemon = Daemons.Current;

            stream.BeginWrite(buffer, offset, size,
                             asyncResult =>
                             {
                                 stream.EndWrite(asyncResult);
                                 ((IDaemon)asyncResult.AsyncState).Schedule(continuation);
                             }, daemon);
        }
开发者ID:ArturD,项目名称:Daemons,代码行数:11,代码来源:StreamExtensions.cs

示例15: WriteAsync

 public static Task WriteAsync(this Stream stream, byte[] buffer)
 {
     try
     {
         return Task.Factory.FromAsync((cb, state) => stream.BeginWrite(buffer, 0, buffer.Length, cb, state), ar => stream.EndWrite(ar), null);
     }
     catch (System.Exception ex)
     {
         return TaskAsyncHelper.FromError(ex);
     }
 }
开发者ID:OleksandrKulchytskyi,项目名称:Sharedeployed,代码行数:11,代码来源:StreamUtils.cs


注:本文中的this.BeginWrite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。