<?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%2FCSharp_Tutorial%2FFile_Directory_Stream%2FAsynchronous_Input_Output</id>
		<title>Csharp/CSharp Tutorial/File Directory 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%2FCSharp_Tutorial%2FFile_Directory_Stream%2FAsynchronous_Input_Output"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/File_Directory_Stream/Asynchronous_Input_Output&amp;action=history"/>
		<updated>2026-04-30T00:58:00Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/File_Directory_Stream/Asynchronous_Input_Output&amp;diff=6756&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/File_Directory_Stream/Asynchronous_Input_Output&amp;diff=6756&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</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/CSharp_Tutorial/File_Directory_Stream/Asynchronous_Input_Output&amp;diff=6757&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/File_Directory_Stream/Asynchronous_Input_Output&amp;diff=6757&amp;oldid=prev"/>
				<updated>2010-05-26T12:20:21Z</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;==Async File Stream==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
using System.IO;&lt;br /&gt;
class Program {&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Main thread started. ThreadID = {0}&amp;quot;, Thread.CurrentThread.GetHashCode());&lt;br /&gt;
        FileStream fs = new FileStream(&amp;quot;logfile.txt&amp;quot;, FileMode.Append, FileAccess.Write, FileShare.None, 4096, true);&lt;br /&gt;
        string msg = &amp;quot;this is a test&amp;quot;;&lt;br /&gt;
        byte[] buffer = Encoding.ASCII.GetBytes(msg);&lt;br /&gt;
        fs.BeginWrite(buffer, 0, buffer.Length, new AsyncCallback(WriteDone), fs);&lt;br /&gt;
    }&lt;br /&gt;
    private static void WriteDone(IAsyncResult ar) {&lt;br /&gt;
        Console.WriteLine(&amp;quot;AsyncCallback method on ThreadID = {0}&amp;quot;, Thread.CurrentThread.GetHashCode());&lt;br /&gt;
        Stream s = (Stream)ar.AsyncState;&lt;br /&gt;
        s.EndWrite(ar);&lt;br /&gt;
        s.Close();&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Async FileStream demo==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
  class Program&lt;br /&gt;
  {&lt;br /&gt;
    static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
      FileStream fs = new FileStream(&amp;quot;logfile.txt&amp;quot;, FileMode.Append,FileAccess.Write, FileShare.None, 4096, true);&lt;br /&gt;
      string msg = &amp;quot;this is a test&amp;quot;;&lt;br /&gt;
      byte[] buffer = Encoding.ASCII.GetBytes(msg);&lt;br /&gt;
      fs.BeginWrite(buffer, 0, buffer.Length,new AsyncCallback(WriteDone), fs);&lt;br /&gt;
    }&lt;br /&gt;
    private static void WriteDone(IAsyncResult ar)&lt;br /&gt;
    {&lt;br /&gt;
      Stream s = (Stream)ar.AsyncState;&lt;br /&gt;
      s.EndWrite(ar);&lt;br /&gt;
      s.Close();&lt;br /&gt;
    }&lt;br /&gt;
  }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Asynchronous I/O==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  private static FileStream inStream;&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;
  }&lt;br /&gt;
  public static void Main() &lt;br /&gt;
  {&lt;br /&gt;
    inStream = new FileStream(&amp;quot;C:\\text.txt&amp;quot;, FileMode.Open, FileAccess.Read, FileShare.None, 2048, true);&lt;br /&gt;
    AsyncCallback  acb = new AsyncCallback(OnComplete);&lt;br /&gt;
    byte[] buf = new byte[50];&lt;br /&gt;
    &lt;br /&gt;
    inStream.BeginRead(buf, 0, 50, acb, null);&lt;br /&gt;
    for(int i=0; i&amp;lt;10; i++)&lt;br /&gt;
      Console.WriteLine(i);&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;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Asynchronous I/O, some blocking on the main thread==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Collections.Specialized;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.IO.rupression;&lt;br /&gt;
using System.Net;&lt;br /&gt;
using System.Net.Mail;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        using (Stream s = new FileStream(&amp;quot;c:\\test.txt&amp;quot;, FileMode.Open))&lt;br /&gt;
        {&lt;br /&gt;
            byte[] buffer = new byte[4096];&lt;br /&gt;
            int bytesRead;&lt;br /&gt;
            do&lt;br /&gt;
            {&lt;br /&gt;
                IAsyncResult ar = s.BeginRead(buffer, 0, buffer.Length, null, null);&lt;br /&gt;
                bytesRead = s.EndRead(ar);&lt;br /&gt;
            }&lt;br /&gt;
            while (bytesRead == buffer.Length);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Asynchronous IO with AsyncCallback==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Text;&lt;br /&gt;
   public class MainClass&lt;br /&gt;
   {&lt;br /&gt;
      static Stream inputStream;&lt;br /&gt;
      static AsyncCallback myCallBack;&lt;br /&gt;
      static byte[] buffer;&lt;br /&gt;
      static int BufferSize = 256;&lt;br /&gt;
      public static void Main()&lt;br /&gt;
      {&lt;br /&gt;
         inputStream = File.OpenRead(&amp;quot;AskTim.txt&amp;quot; );&lt;br /&gt;
         buffer = new byte[BufferSize];&lt;br /&gt;
         myCallBack = new AsyncCallback( OnCompletedRead );&lt;br /&gt;
         inputStream.BeginRead(&lt;br /&gt;
            buffer,             // holds the results&lt;br /&gt;
            0,                  // offset&lt;br /&gt;
            buffer.Length,      // (BufferSize)&lt;br /&gt;
            myCallBack,         // call back delegate&lt;br /&gt;
            null );             // local state object&lt;br /&gt;
      }&lt;br /&gt;
      static void OnCompletedRead( IAsyncResult asyncResult )&lt;br /&gt;
      {&lt;br /&gt;
         int bytesRead = inputStream.EndRead( asyncResult );&lt;br /&gt;
         if ( bytesRead &amp;gt; 0 ){&lt;br /&gt;
            String s = Encoding.ASCII.GetString( buffer, 0, bytesRead );&lt;br /&gt;
            Console.WriteLine( s );&lt;br /&gt;
            inputStream.BeginRead(buffer, 0, buffer.Length, myCallBack, null );&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>