本文整理匯總了VB.NET中System.IO.FileStream.IsAsync屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET FileStream.IsAsync屬性的具體用法?VB.NET FileStream.IsAsync怎麽用?VB.NET FileStream.IsAsync使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.IO.FileStream
的用法示例。
在下文中一共展示了FileStream.IsAsync屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Main
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