{"action":"created","issue":{"url":"https://api.github.com/repos/HangfireIO/Hangfire/issues/646","repository_url":"https://api.github.com/repos/HangfireIO/Hangfire","labels_url":"https://api.github.com/repos/HangfireIO/Hangfire/issues/646/labels{/name}","comments_url":"https://api.github.com/repos/HangfireIO/Hangfire/issues/646/comments","events_url":"https://api.github.com/repos/HangfireIO/Hangfire/issues/646/events","html_url":"https://github.com/HangfireIO/Hangfire/issues/646","id":171472342,"number":646,"title":"Job validation prevents waiting on a Task returned from a method","user":{"login":"amattie","id":510021,"avatar_url":"https://avatars.githubusercontent.com/u/510021?v=3","gravatar_id":"","url":"https://api.github.com/users/amattie","html_url":"https://github.com/amattie","followers_url":"https://api.github.com/users/amattie/followers","following_url":"https://api.github.com/users/amattie/following{/other_user}","gists_url":"https://api.github.com/users/amattie/gists{/gist_id}","starred_url":"https://api.github.com/users/amattie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amattie/subscriptions","organizations_url":"https://api.github.com/users/amattie/orgs","repos_url":"https://api.github.com/users/amattie/repos","events_url":"https://api.github.com/users/amattie/events{/privacy}","received_events_url":"https://api.github.com/users/amattie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-16T17:28:20Z","updated_at":"2016-08-16T23:08:11Z","closed_at":null,"body":"_Hangfire.Core 1.6.2_\r\n\r\nI'm trying to schedule a recurring job like this:\r\n\r\n`RecurringJob.AddOrUpdate<MyClass>((_) => _.Run().Wait(), Cron.MinuteInterval(1));`\r\n\r\nMy MyClass.Run method has this signature:\r\n\r\n`public async Task Run() { }`\r\n\r\nHangfire throws an ArgumentException during runtime due to Job's Validate method. This is the specific culprit: https://github.com/HangfireIO/Hangfire/blob/4dec6435fb552364833c359079230ad04fd98e53/src/Hangfire.Core/Common/Job.cs#L384.\r\n\r\nIs Hangfire being over-protective here? Even if I can't run fully async, it feels like I should be able to call .Wait() on a Task that's returned from a method on MyClass.\r\n\r\nI believe this issue is different than #150 and the discussion on https://discuss.hangfire.io/t/async-task-jobs/73."},"comment":{"url":"https://api.github.com/repos/HangfireIO/Hangfire/issues/comments/240267076","html_url":"https://github.com/HangfireIO/Hangfire/issues/646#issuecomment-240267076","issue_url":"https://api.github.com/repos/HangfireIO/Hangfire/issues/646","id":240267076,"user":{"login":"amattie","id":510021,"avatar_url":"https://avatars.githubusercontent.com/u/510021?v=3","gravatar_id":"","url":"https://api.github.com/users/amattie","html_url":"https://github.com/amattie","followers_url":"https://api.github.com/users/amattie/followers","following_url":"https://api.github.com/users/amattie/following{/other_user}","gists_url":"https://api.github.com/users/amattie/gists{/gist_id}","starred_url":"https://api.github.com/users/amattie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amattie/subscriptions","organizations_url":"https://api.github.com/users/amattie/orgs","repos_url":"https://api.github.com/users/amattie/repos","events_url":"https://api.github.com/users/amattie/events{/privacy}","received_events_url":"https://api.github.com/users/amattie/received_events","type":"User","site_admin":false},"created_at":"2016-08-16T23:08:11Z","updated_at":"2016-08-16T23:08:11Z","body":"Interesting, that works. I didn't realize that argument was an expression tree, and it doesn't help that Roslyn doesn't explicitly realize it's an expression tree either and thus triggers a [CS4014 warning](https://msdn.microsoft.com/en-us/library/hh873131.aspx?f=255&MSPPError=-2147217396) during build. The Visual Studio UI also highlights it as a potential problem due to that warning.\r\n\r\nIt still feels like Hangfire is being overly protective here, but I also don't know the consequences of treating this argument as a delegate and allowing `.Wait()` to be called. I'm leaving this open due to the build warning this causes, but feel free to close if you disagree."}}
{"actor":{"display_login":"amattie"}}