public interface IAsyncResult
mscorlib
BCL
Supported by objects that represent the state of an asynchronous operation.
An object that supports the IAsyncResult interface stores state information for an asynchronous operation, and provides a synchronization object to allow threads to be signaled when the operation completes.IAsyncResult objects are returned by methods that begin asynchronous operations, such as System.IO.FileStream.BeginRead(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object), and are passed to methods used to complete asynchronous operations, such as System.IO.FileStream.EndRead(System.IAsyncResult). IAsyncResult objects are also passed to methods invoked by AsyncCallback delegates when an asynchronous operation completes.
System Namespace
IAsyncResult Properties
IAsyncResult.AsyncState Property
IAsyncResult.AsyncWaitHandle Property
IAsyncResult.CompletedSynchronously Property
IAsyncResult.IsCompleted Property
object AsyncState { get; }
Gets the user-provided state object supplied at the time the asynchronous operation was started.
The supplied Object.
[Behaviors: The object returned by this property is required to be the object specified as the last parameter to methods that begin asynchronous operations, such as System.IO.FileStream.BeginRead(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object).This property is read-only.
]
[Overrides: Implement this property to allow the caller of an asynchronous operation to obtain an application-defined object specified at the start of the operation. ]
[Usage: The object returned by this property can be used to pass state information for the asynchronous operation to a AsyncCallback delegate. ]
System.IAsyncResult Interface, System Namespace
WaitHandle AsyncWaitHandle { get; }
Gets a WaitHandle that can be used to block a thread until an asynchronous operation completes.
A WaitHandle that is signaled when an asynchronous operation completes.
[Behaviors: The object returned by System.IAsyncResult.AsyncWaitHandle can be allocated in advance or on demand. However, once allocated it is required to be kept alive until the user calls a method that ends the asynchronous operation, such as System.IO.FileStream.EndRead(System.IAsyncResult). Only after the operation completes or is canceled, can the object be disposed of.[Note:
WaitHandle
supplies methods that support waiting for synchronization objects to become signaled, such as System.Threading.WaitHandle.WaitOne(System.Int32,System.Boolean) .]
This property is read-only.
]
[Usage: Clients that wait for the operation to complete (as opposed to polling), use this property to obtain a synchronization object to wait on.
]
System.IAsyncResult Interface, System Namespace
bool CompletedSynchronously { get; }
Gets a Boolean value that specifies whether the asynchronous operation completed synchronously.
true
if the operation synchronously; otherwisefalse
.
[Behaviors: As described above.[Note: Most implementations of the IAsyncResult interface will not use this property, and should return
false
.]
This property is read-only.
]
[Usage: Use this property to determine if the asynchronous operation completed synchronously. For example, this property can return
true
for an asynchronous IO operation if the IO request was small. ]
System.IAsyncResult Interface, System Namespace
bool IsCompleted { get; }
Gets a Boolean value that specifies whether an asynchronous operation has completed.
true
if the operation has completed; otherwisefalse
.
[Behaviors: As described above.This property is read-only.
]
[Usage: Clients that poll for operation status (as opposed to waiting on a synchronization object) use this property to determine the status of the operation.
]
System.IAsyncResult Interface, System Namespace