{"action":"created","issue":{"url":"https://api.github.com/repos/akkadotnet/akka.net/issues/660","labels_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/660/labels{/name}","comments_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/660/comments","events_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/660/events","html_url":"https://github.com/akkadotnet/akka.net/pull/660","id":58229919,"number":660,"title":"Proposal for an AsyncUntypedActor.","user":{"login":"nvivo","id":202449,"avatar_url":"https://avatars.githubusercontent.com/u/202449?v=3","gravatar_id":"","url":"https://api.github.com/users/nvivo","html_url":"https://github.com/nvivo","followers_url":"https://api.github.com/users/nvivo/followers","following_url":"https://api.github.com/users/nvivo/following{/other_user}","gists_url":"https://api.github.com/users/nvivo/gists{/gist_id}","starred_url":"https://api.github.com/users/nvivo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nvivo/subscriptions","organizations_url":"https://api.github.com/users/nvivo/orgs","repos_url":"https://api.github.com/users/nvivo/repos","events_url":"https://api.github.com/users/nvivo/events{/privacy}","received_events_url":"https://api.github.com/users/nvivo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-19T16:18:48Z","updated_at":"2015-02-28T20:22:16Z","closed_at":"2015-02-28T20:22:16Z","pull_request":{"url":"https://api.github.com/repos/akkadotnet/akka.net/pulls/660","html_url":"https://github.com/akkadotnet/akka.net/pull/660","diff_url":"https://github.com/akkadotnet/akka.net/pull/660.diff","patch_url":"https://github.com/akkadotnet/akka.net/pull/660.patch"},"body":"This actor allows to use tasks inside Receive but have the same behavior as a normal actor. It's implemented as a state machine. If any messages arrive during async processing, they will be stashed until the current processing is done. If exceptions are thrown during async operations, they will be handled by the supervisor as if it was a synchronous operation.\r\n\r\nExample:\r\n\r\n```cs\r\npublic class MyAsyncActor : AsyncUntypedActor\r\n{\r\n    protected override async Task OnReceiveAsync(object message)\r\n    {\r\n        // keep the sender, because it will lose context after \"await\" in 0.8\r\n        var sender = Sender;\r\n\r\n        var values = await DoSomeDatabaseWork();\r\n\r\n        sender.Tell(values);\r\n    }\r\n}\r\n``` \r\n\r\nIt will also behave as a normal UntypedActor if the task is synchronous. That means that if you return a completed task, it won't cause any overhead in processing.\r\n\r\nLet me know if there are any issues or suggestions."},"comment":{"url":"https://api.github.com/repos/akkadotnet/akka.net/issues/comments/76544073","html_url":"https://github.com/akkadotnet/akka.net/pull/660#issuecomment-76544073","issue_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/660","id":76544073,"user":{"login":"Aaronontheweb","id":326939,"avatar_url":"https://avatars.githubusercontent.com/u/326939?v=3","gravatar_id":"","url":"https://api.github.com/users/Aaronontheweb","html_url":"https://github.com/Aaronontheweb","followers_url":"https://api.github.com/users/Aaronontheweb/followers","following_url":"https://api.github.com/users/Aaronontheweb/following{/other_user}","gists_url":"https://api.github.com/users/Aaronontheweb/gists{/gist_id}","starred_url":"https://api.github.com/users/Aaronontheweb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aaronontheweb/subscriptions","organizations_url":"https://api.github.com/users/Aaronontheweb/orgs","repos_url":"https://api.github.com/users/Aaronontheweb/repos","events_url":"https://api.github.com/users/Aaronontheweb/events{/privacy}","received_events_url":"https://api.github.com/users/Aaronontheweb/received_events","type":"User","site_admin":false},"created_at":"2015-02-28T20:22:16Z","updated_at":"2015-02-28T20:22:16Z","body":"Closing this - the approach we'd like to go with is something that can be plugged into all actors (although it'll be easier to use in some actors over others - i.e. `ReceiveActor` will have much better built-in support than `UntypedActor` will), rather than just a specific type of actor.\r\n\r\nSee the latest on #686 "}}