IAsyncResult.CompletedSynchronously 屬性


取得值,這個值表示非同步作業是否同步完成。Gets a value that indicates whether the asynchronous operation completed synchronously.

 property bool CompletedSynchronously { bool get(); };
public bool CompletedSynchronously { get; }
member this.CompletedSynchronously : bool
Public ReadOnly Property CompletedSynchronously As Boolean



如果非同步作業同步完成,則為 true;否則為 falsetrue if the asynchronous operation completed synchronously; otherwise, false.


如果在委派中偵測到同步完成呼叫,則 AsyncCallback 啟動非同步作業的執行緒可能是目前的執行緒。If the synchronous completion of the call is detected in the AsyncCallback delegate, it is probable that the thread that initiated the asynchronous operation is the current thread.


大部分的介面實作者 IAsyncResult 都不會使用這個屬性,而且應該會傳回 falseMost implementers of the IAsyncResult interface will not use this property and should return false. 從開始 .NET Framework 4.5.NET Framework 4.5FromAsync(IAsyncResult, Action<IAsyncResult>, TaskCreationOptions) 如果未正確執行此屬性,以方法建立的工作將不會完成。Beginning with the .NET Framework 4.5.NET Framework 4.5, a task that is created with the FromAsync(IAsyncResult, Action<IAsyncResult>, TaskCreationOptions) method will not complete if this property is not implemented correctly. 請參閱 4.5 中的應用程式相容性See Application Compatibility in 4.5.


使用這個屬性來判斷非同步作業是否同步完成。Use this property to determine if the asynchronous operation completed synchronously. 例如,如果 i/o 要求很小,則這個屬性可能會傳回 true 非同步 i/o 作業。For example, this property can return true for an asynchronous I/O operation if the I/O request was small.