實作 use和 use!關鍵字在 非同步計算的運算式。
命名空間/模組路徑: Microsoft.FSharp.Control
組件:FSharp.Core (在 FSharp.Core.dll 中)
// Signature:
member this.Using : 'T * ('T -> Async<'U>) -> Async<'U> (requires 'T :> IDisposable)
// Usage:
asyncBuilder.Using (resource, binder)
參數
resource
型別:'T要使用和處置的資源。
binder
型別:'T -> Async<'U>函式,會接受資源並傳回非同步計算。
傳回值
非同步計算,會繫結再最終處置 resource。
備註
建立會執行 binder(resource) 的非同步計算。 當此計算產生結果,或當非同步計算因為例外狀況或取消而結束時,會執行動作 resource.Dispose()。
執行計算之後,便會執行取消檢查。 如果這個方法存在,則允許將 use 和 use! 用於 async { ... } 計算運算式語法。
平台
Windows 7、Windows Vista SP2、Windows XP SP3、Windows XP x64 SP2、Windows Server 2008 R2、Windows Server 2008 SP2、Windows Server 2003 SP2
版本資訊
F# 執行階段
支援版本:2.0、4.0
Silverlight
支援版本:3