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


C# System.IO.Stream.BeginRead方法代码示例

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


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

示例1: Load

        public void Load(SafeUri uri)
        {
            if (is_disposed)
                return;

            //First, send a thumbnail if we have one
            if ((thumb = XdgThumbnailSpec.LoadThumbnail (uri, ThumbnailSize.Large, null)) != null) {
                pixbuf_orientation = ImageOrientation.TopLeft;
                EventHandler<AreaPreparedEventArgs> prep = AreaPrepared;
                if (prep != null)
                    prep (this, new AreaPreparedEventArgs (true));
                EventHandler<AreaUpdatedEventArgs> upd = AreaUpdated;
                if (upd != null)
                    upd (this, new AreaUpdatedEventArgs (new Rectangle (0, 0, thumb.Width, thumb.Height)));
            }

            using (var image_file = ImageFile.Create (uri)) {
                image_stream = image_file.PixbufStream ();
                pixbuf_orientation = image_file.Orientation;
            }

            loading = true;
            // The ThreadPool.QueueUserWorkItem hack is there cause, as the bytes to read are present in the stream,
            // the Read is CompletedAsynchronously, blocking the mainloop
            image_stream.BeginRead (buffer, 0, count, delegate (IAsyncResult r) {
                ThreadPool.QueueUserWorkItem (delegate {HandleReadDone (r);});
            }, null);
        }
开发者ID:nathansamson,项目名称:F-Spot-Album-Exporter,代码行数:28,代码来源:GdkImageLoader.cs

示例2: GetResponseCallback

            void GetResponseCallback(IAsyncResult asyncResult)
            {
                try
                {
                    WebResponse = WebRequest.EndGetResponse(asyncResult);
                    Stream = WebResponse.GetResponseStream();

                    BufferOffset = 0;
                    Stream.BeginRead(Buffer, BufferOffset, Buffer.Length, ReadCallback, null);
                }
                catch(System.Exception e)
                {
                    Exception = e;
                }
            }
开发者ID:dpull,项目名称:UnityUtils,代码行数:15,代码来源:DNS.cs

示例3: Copy

 /// <summary>
 /// Transfers an entire source stream to a target
 /// </summary>
 /// <param name="source">
 /// The stream to read
 /// </param>
 /// <param name="target">
 /// The stream to write
 /// </param>
 /// <returns>
 /// The total number of bytes transferred
 /// </returns>
 public Int32 Copy(Stream source, Stream target)
 {
     var copied = 0;
      var bufferIdx = 0;
      // start an initial dummy write to avoid
      // a null test within the copy loop
      var writer = target.BeginWrite(this.buffers[1], 0, 0, null, null);
      for (; ; )
      {
     // read into the current buffer
     var buffer = this.buffers[bufferIdx];
     var reader = source.BeginRead(buffer, 0, buffer.Length, null, null);
     // complete the previous write and the current read
     target.EndWrite(writer);
     var read = source.EndRead(reader);
     if (read == 0)
        break;
     copied += read;
     // start the next write for the completed read
     writer = target.BeginWrite(buffer, 0, read, null, null);
     // swap the buffer index for the next read
     bufferIdx = (bufferIdx + 1) % 2;
      }
      return copied;
 }
开发者ID:bspell1,项目名称:SkyFloe,代码行数:37,代码来源:StreamCopier.cs

示例4: startReceive

 public void startReceive(IAsyncResult res)
 {
     try
     {
         download_response = (HttpWebResponse)download_request.EndGetResponse(res);
         total = (int)download_response.ContentLength;
         downloaded = 0;
         onprogress(null, 0, total, 0);
         stream = download_response.GetResponseStream();
         stream.BeginRead(buffer, 0, 65536, downloading, this);
     }
     catch (Exception e)
     {
         failure("Error " + action, e);
     }
 }
开发者ID:passerellesnumeriques,项目名称:Students-Database,代码行数:16,代码来源:ServerRequest.cs

示例5: startReceive

 public void startReceive(IAsyncResult res)
 {
     try
     {
         response = (HttpWebResponse)request.EndGetResponse(res);
         response_stream = response.GetResponseStream();
         response_stream.BeginRead(buffer, 0, buffer.Length, downloading, this);
     }
     catch (Exception e)
     {
         failure("Error receiving response from server after upload", e);
     }
 }
开发者ID:passerellesnumeriques,项目名称:Students-Database,代码行数:13,代码来源:DocumentUpload.cs


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