FileStream.IsAsync プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)


IsAsync プロパティは、FileStream ハンドルが非同期的に開かれたかどうかを検出し、コードで Handle プロパティを正しく使用できるようにします。Win32 では、IsAsync が TRUE の場合は、重複 I/O 用にハンドルが開かれ、ReadFile と WriteFile で異なるパラメータが要求されます。
Windows 98, Windows Millennium Edition プラットフォームメモ : これらのオペレーティング システムは、非同期 I/O をサポートしていません。これらのプラットフォーム用のコードが非同期的にファイルを開くことを要求する場合にも、共通言語ランタイムは同期的にファイルを開きます。

次のコード例は、FileStream(String,FileMode,FileAccess,FileShare,Int32,Boolean) コンストラクタの例の一部です。
Shared Sub Main() ' Create a synchronization object that gets ' signaled when verification is complete. Dim manualEvent As New ManualResetEvent(False) ' Create random data to write to the file. Dim writeArray(100000) As Byte Dim randomGenerator As New Random() randomGenerator.NextBytes(writeArray) Dim fStream As New FileStream("Test#@@#.dat", _ FileMode.Create, FileAccess.ReadWrite, _ FileShare.None, 4096, True) ' Check that the FileStream was opened asynchronously. If fStream.IsAsync = True Console.WriteLine("fStream was opened asynchronously.") Else Console.WriteLine("fStream was not opened asynchronously.") End If ' Asynchronously write to the file. Dim asyncResult As IAsyncResult = fStream.BeginWrite( _ writeArray, 0, writeArray.Length, _ AddressOf EndWriteCallback , _ New State(fStream, writeArray, manualEvent)) ' Concurrently do other work and then wait ' for the data to be written and verified. manualEvent.WaitOne(5000, False) End Sub
static void Main() { // Create a synchronization object that gets // signaled when verification is complete. ManualResetEvent manualEvent = new ManualResetEvent(false); // Create random data to write to the file. byte[] writeArray = new byte[100000]; new Random().NextBytes(writeArray); FileStream fStream = new FileStream("Test#@@#.dat", FileMode.Create, FileAccess.ReadWrite, FileShare.None, 4096, true); // Check that the FileStream was opened asynchronously. Console.WriteLine("fStream was {0}opened asynchronously.", fStream.IsAsync ? "" : "not "); // Asynchronously write to the file. IAsyncResult asyncResult = fStream.BeginWrite( writeArray, 0, writeArray.Length, new AsyncCallback(EndWriteCallback), new State(fStream, writeArray, manualEvent)); // Concurrently do other work and then wait // for the data to be written and verified. manualEvent.WaitOne(5000, false); }
int main() { // Create a synchronization object that gets // signaled when verification is complete. ManualResetEvent^ manualEvent = gcnew ManualResetEvent( false ); // Create the data to write to the file. array<Byte>^writeArray = gcnew array<Byte>(100000); (gcnew Random)->NextBytes( writeArray ); FileStream^ fStream = gcnew FileStream( "Test#@@#.dat",FileMode::Create,FileAccess::ReadWrite,FileShare::None,4096,true ); // Check that the FileStream was opened asynchronously. Console::WriteLine( "fStream was {0}opened asynchronously.", fStream->IsAsync ? (String^)"" : "not " ); // Asynchronously write to the file. IAsyncResult^ asyncResult = fStream->BeginWrite( writeArray, 0, writeArray->Length, gcnew AsyncCallback( &FStream::EndWriteCallback ), gcnew State( fStream,writeArray,manualEvent ) ); // Concurrently do other work and then wait // for the data to be written and verified. manualEvent->WaitOne( 5000, false ); }
public static void main(String[] args) { // Create a synchronization object that gets // signaled when verification is complete. ManualResetEvent manualEvent = new ManualResetEvent(false); // Create random data to write to the file. ubyte writeArray[] = new ubyte[100000]; new Random().NextBytes(writeArray); FileStream fStream = new FileStream("Test#@@#.dat", FileMode.Create, FileAccess.ReadWrite, FileShare.None, 4096, true); // Check that the FileStream was opened asynchronously. Console.WriteLine("fStream was {0}opened asynchronously.", (fStream.get_IsAsync()) ? "" : "not "); FStream classfStream = new FStream(); // Asynchronously write to the file. IAsyncResult asyncResult = fStream.BeginWrite(writeArray, 0, writeArray.length, new AsyncCallback(EndWriteCallback) , classfStream.new State(fStream, writeArray, manualEvent)); // Concurrently do other work and then wait // for the data to be written and verified. manualEvent.WaitOne(5000, false); } //main

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からFileStream.IsAsync プロパティを検索する場合は、下記のリンクをクリックしてください。

- FileStream.IsAsync プロパティのページへのリンク