<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FFile_Stream%2FAsynchronous_Input_output</id>
		<title>Csharp/C Sharp/File Stream/Asynchronous Input output - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FFile_Stream%2FAsynchronous_Input_output"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/Asynchronous_Input_output&amp;action=history"/>
		<updated>2026-04-29T17:40:14Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/Asynchronous_Input_output&amp;diff=1308&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/Asynchronous_Input_output&amp;diff=1308&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/Asynchronous_Input_output&amp;diff=1309&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/Asynchronous_Input_output&amp;diff=1309&amp;oldid=prev"/>
				<updated>2010-05-26T11:45:37Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Asynchronous Writing, Asynchronous Reading==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
//Code revised from Chapter 25 - Accessing Data Streams&lt;br /&gt;
//C# Bible&lt;br /&gt;
//by Jeff Ferguson et al. &lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
   &lt;br /&gt;
class FileTestClass&lt;br /&gt;
{&lt;br /&gt;
    private static FileStream    BinaryFile = new FileStream(&amp;quot;test.dat&amp;quot;, FileMode.Create, FileAccess.ReadWrite);&lt;br /&gt;
    private static byte []       ByteArray = new byte [256];&lt;br /&gt;
    private static IAsyncResult  AsyncReadResultImplementation = null;&lt;br /&gt;
    private static IAsyncResult  AsyncWriteResultImplementation;&lt;br /&gt;
    private static AsyncCallback ReadBytesCompleteCallback = new AsyncCallback(OnReadBytesComplete);&lt;br /&gt;
    private static AsyncCallback WriteBytesCompleteCallback = new AsyncCallback(OnWriteBytesComplete);&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
    public static void OnReadBytesComplete(IAsyncResult AsyncResult)&lt;br /&gt;
    {&lt;br /&gt;
        int BytesRead;&lt;br /&gt;
        int Failures;&lt;br /&gt;
   &lt;br /&gt;
        BytesRead = BinaryFile.EndRead(AsyncResult);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Bytes read........: {0}&amp;quot;, BytesRead);&lt;br /&gt;
        Failures = 0;&lt;br /&gt;
        for(int i = 0; i &amp;lt; 256; i++)&lt;br /&gt;
        {&lt;br /&gt;
            if(ByteArray[i] != (byte)i)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Read test failed for byte at offset {0}.&amp;quot;, i);&lt;br /&gt;
                Failures++;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        Console.WriteLine(&amp;quot;Read test failures: {0}&amp;quot;, Failures);&lt;br /&gt;
    }&lt;br /&gt;
    public static void OnWriteBytesComplete(IAsyncResult AsyncResult)&lt;br /&gt;
    {&lt;br /&gt;
        BinaryFile.EndWrite(AsyncResult);&lt;br /&gt;
    }&lt;br /&gt;
    static public void Main()&lt;br /&gt;
    {&lt;br /&gt;
        for(int i = 0; i &amp;lt; 256; i++)&lt;br /&gt;
            ByteArray[i] = (byte)i;&lt;br /&gt;
        AsyncWriteResultImplementation = BinaryFile.BeginWrite(ByteArray, 0, 256, WriteBytesCompleteCallback, null);&lt;br /&gt;
&lt;br /&gt;
        WaitHandle WaitOnWriteIO = AsyncWriteResultImplementation.AsyncWaitHandle;&lt;br /&gt;
        WaitOnWriteIO.WaitOne();&lt;br /&gt;
&lt;br /&gt;
        BinaryFile.Seek(0, SeekOrigin.Begin);&lt;br /&gt;
        AsyncReadResultImplementation = BinaryFile.BeginRead(ByteArray, 0, 256, ReadBytesCompleteCallback, null);&lt;br /&gt;
        WaitHandle WaitOnReadIO = AsyncReadResultImplementation.AsyncWaitHandle;&lt;br /&gt;
        WaitOnReadIO.WaitOne();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==illustrates asynchronous I/O==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
 /*&lt;br /&gt;
  Example15_18.cs illustrates asynchronous I/O&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
public class Example15_18 &lt;br /&gt;
{&lt;br /&gt;
  // stream to handle reading&lt;br /&gt;
  private static FileStream inStream;&lt;br /&gt;
  // delegated method to handle callback&lt;br /&gt;
  private static AsyncCallback acb;&lt;br /&gt;
  // allocate a big buffer for reading&lt;br /&gt;
  static byte[] buf = new byte[500000];&lt;br /&gt;
  // callback to use when read is complete&lt;br /&gt;
  static void OnComplete(IAsyncResult asyncResult)&lt;br /&gt;
  {&lt;br /&gt;
    int bytesRead = inStream.EndRead(asyncResult);&lt;br /&gt;
    Console.Write(bytesRead);&lt;br /&gt;
    Console.WriteLine(&amp;quot; bytes read!&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
    &lt;br /&gt;
    [STAThread]&lt;br /&gt;
  public static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    // use an open file dialog to get a filename&lt;br /&gt;
    OpenFileDialog dlgOpen = new OpenFileDialog();&lt;br /&gt;
    dlgOpen.Title=&amp;quot;Select file to read&amp;quot;;&lt;br /&gt;
    if (dlgOpen.ShowDialog() == DialogResult.OK)&lt;br /&gt;
    {&lt;br /&gt;
      // open the file&lt;br /&gt;
      inStream = new FileStream(dlgOpen.FileName, FileMode.Open, &lt;br /&gt;
       FileAccess.Read, FileShare.None, 2048, true);&lt;br /&gt;
      // assign the callback delegate&lt;br /&gt;
      acb = new AsyncCallback(OnComplete);&lt;br /&gt;
      // read asynchronously&lt;br /&gt;
      inStream.BeginRead(buf, 0, 500000, acb, null);&lt;br /&gt;
      // do some work in the meantime&lt;br /&gt;
      for(int i=0; i&amp;lt;10; i++)&lt;br /&gt;
        Console.WriteLine(i);&lt;br /&gt;
      // And wait for the user to quit&lt;br /&gt;
      Console.WriteLine(&amp;quot;Press Enter to exit&amp;quot;);&lt;br /&gt;
      int resp = Console.Read();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Synchronous Writing, Asynchronous Reading==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
//Code revised from Chapter 25 - Accessing Data Streams&lt;br /&gt;
//C# Bible&lt;br /&gt;
//by Jeff Ferguson et al. &lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
   &lt;br /&gt;
class FileTestClass&lt;br /&gt;
{&lt;br /&gt;
    private static FileStream    BinaryFile = new FileStream(&amp;quot;test.dat&amp;quot;, FileMode.Create, FileAccess.ReadWrite);&lt;br /&gt;
    private static byte []       ByteArray = new byte [256];&lt;br /&gt;
    private static IAsyncResult  AsyncResultImplementation;&lt;br /&gt;
    private static AsyncCallback ReadBytesCompleteCallback= new AsyncCallback(OnReadBytesComplete);&lt;br /&gt;
    public static void OnReadBytesComplete(IAsyncResult AsyncResult)&lt;br /&gt;
    {&lt;br /&gt;
        int BytesRead;&lt;br /&gt;
        int Failures;&lt;br /&gt;
   &lt;br /&gt;
        BytesRead = BinaryFile.EndRead(AsyncResult);&lt;br /&gt;
        Failures = 0;&lt;br /&gt;
        for(int i = 0; i &amp;lt; 256; i++)&lt;br /&gt;
        {&lt;br /&gt;
            if(ByteArray[i] != (byte)i)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Read test failed for byte at offset {0}.&amp;quot;, i);&lt;br /&gt;
                Failures++;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static public void Main()&lt;br /&gt;
    {&lt;br /&gt;
        for(int i = 0; i &amp;lt; 256; i++)&lt;br /&gt;
            ByteArray[i] = (byte)i;&lt;br /&gt;
        BinaryFile.Write(ByteArray, 0, 256);&lt;br /&gt;
        BinaryFile.Seek(0, SeekOrigin.Begin);&lt;br /&gt;
        AsyncResultImplementation = BinaryFile.BeginRead(ByteArray, 0, 256, ReadBytesCompleteCallback, null);&lt;br /&gt;
        WaitHandle WaitOnReadIO = AsyncResultImplementation.AsyncWaitHandle;&lt;br /&gt;
        WaitOnReadIO.WaitOne();&lt;br /&gt;
    }    &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>