{"action":"closed","issue":{"url":"https://api.github.com/repos/fsprojects/FSharpx.Extras/issues/348","repository_url":"https://api.github.com/repos/fsprojects/FSharpx.Extras","labels_url":"https://api.github.com/repos/fsprojects/FSharpx.Extras/issues/348/labels{/name}","comments_url":"https://api.github.com/repos/fsprojects/FSharpx.Extras/issues/348/comments","events_url":"https://api.github.com/repos/fsprojects/FSharpx.Extras/issues/348/events","html_url":"https://github.com/fsprojects/FSharpx.Extras/issues/348","id":183557435,"number":348,"title":"TaskBuilder.TryFinally runs finally block immediately","user":{"login":"rspeele","id":1637978,"avatar_url":"https://avatars.githubusercontent.com/u/1637978?v=3","gravatar_id":"","url":"https://api.github.com/users/rspeele","html_url":"https://github.com/rspeele","followers_url":"https://api.github.com/users/rspeele/followers","following_url":"https://api.github.com/users/rspeele/following{/other_user}","gists_url":"https://api.github.com/users/rspeele/gists{/gist_id}","starred_url":"https://api.github.com/users/rspeele/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rspeele/subscriptions","organizations_url":"https://api.github.com/users/rspeele/orgs","repos_url":"https://api.github.com/users/rspeele/repos","events_url":"https://api.github.com/users/rspeele/events{/privacy}","received_events_url":"https://api.github.com/users/rspeele/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-17T23:53:24Z","updated_at":"2016-10-31T08:40:34Z","closed_at":"2016-10-31T08:40:34Z","body":"Hi,\n\nThanks for developing this project; it has been a helpful reference!\n\nThought you should be aware that TaskBuilder's [TryFinally method](https://github.com/fsprojects/FSharpx.Extras/blob/master/src/FSharpx.Extras/ComputationExpressions/Monad.fs#L1058) runs the \"compensation\" function immediately, as its \"try\" block just returns the task it was given.\n\nThis makes both it and `Using` pointless, as far as I can tell. For example, the following program will fail with an `ObjectDisposedException` because the file has already been disposed before the `WriteLineAsync` method has a chance to run.\n\n```\nopen FSharpx.Task\nopen System.Threading.Tasks\nopen System.IO\n\n[<EntryPoint>]\nlet main argv =\n    let t =\n        task {\n            use f = File.CreateText(\"hello.txt\")\n            do! ToTaskUnit <| Task.Delay(100)\n            do! ToTaskUnit <| f.WriteLineAsync(\"hello world\")\n        }\n    t.Wait()\n    0\n```\n"}}
{"actor":{"display_login":"forki"}}