{"action":"created","issue":{"url":"https://api.github.com/repos/Particular/ServiceControl.Plugins.v5/issues/10","labels_url":"https://api.github.com/repos/Particular/ServiceControl.Plugins.v5/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/Particular/ServiceControl.Plugins.v5/issues/10/comments","events_url":"https://api.github.com/repos/Particular/ServiceControl.Plugins.v5/issues/10/events","html_url":"https://github.com/Particular/ServiceControl.Plugins.v5/issues/10","id":101816336,"number":10,"title":"CustomCheck can fail to send report back to ServiceControl","user":{"login":"johnsimons","id":122651,"avatar_url":"https://avatars.githubusercontent.com/u/122651?v=3","gravatar_id":"","url":"https://api.github.com/users/johnsimons","html_url":"https://github.com/johnsimons","followers_url":"https://api.github.com/users/johnsimons/followers","following_url":"https://api.github.com/users/johnsimons/following{/other_user}","gists_url":"https://api.github.com/users/johnsimons/gists{/gist_id}","starred_url":"https://api.github.com/users/johnsimons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnsimons/subscriptions","organizations_url":"https://api.github.com/users/johnsimons/orgs","repos_url":"https://api.github.com/users/johnsimons/repos","events_url":"https://api.github.com/users/johnsimons/events{/privacy}","received_events_url":"https://api.github.com/users/johnsimons/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Particular/ServiceControl.Plugins.v5/labels/Bug","name":"Bug","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-19T06:22:25Z","updated_at":"2015-08-19T07:12:59Z","closed_at":null,"body":"Thes issue seems to be caused by the timer we used to get around DI issues, see https://github.com/Particular/ServiceControl.Plugins.v5/blob/47454d30b0e79c91f1a2dbae0c6e54be3a8769a3/src/ServiceControl.Plugin.CustomChecks/CustomCheck.cs#L55\r\n\r\nSo because the `Timer` is newed up and no reference is kept, the whole instance is available for collection.\r\nHere is a quick replication:\r\n```c#\r\nclass Program\r\n{\r\n    static void Main(string[] args)\r\n    {\r\n        new Program().DelayExecutionForFail(\"ff\");\r\n\r\n        GC.Collect();\r\n\r\n        Console.Read();\r\n    }\r\n\r\n    public void DelayExecutionForFail(object state)\r\n    {\r\n        Console.Out.WriteLine(\"Still ticking\");\r\n\r\n        new Timer(DelayExecutionForFail, state, 2000, -1);\r\n            \r\n    }\r\n}\r\n```\r\n\r\nThe fix is to set the `Timer` instance to a local field in the `CustomCheck` class"},"comment":{"url":"https://api.github.com/repos/Particular/ServiceControl.Plugins.v5/issues/comments/132469546","html_url":"https://github.com/Particular/ServiceControl.Plugins.v5/issues/10#issuecomment-132469546","issue_url":"https://api.github.com/repos/Particular/ServiceControl.Plugins.v5/issues/10","id":132469546,"user":{"login":"johnsimons","id":122651,"avatar_url":"https://avatars.githubusercontent.com/u/122651?v=3","gravatar_id":"","url":"https://api.github.com/users/johnsimons","html_url":"https://github.com/johnsimons","followers_url":"https://api.github.com/users/johnsimons/followers","following_url":"https://api.github.com/users/johnsimons/following{/other_user}","gists_url":"https://api.github.com/users/johnsimons/gists{/gist_id}","starred_url":"https://api.github.com/users/johnsimons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnsimons/subscriptions","organizations_url":"https://api.github.com/users/johnsimons/orgs","repos_url":"https://api.github.com/users/johnsimons/repos","events_url":"https://api.github.com/users/johnsimons/events{/privacy}","received_events_url":"https://api.github.com/users/johnsimons/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T07:12:59Z","updated_at":"2015-08-19T07:12:59Z","body":"@indualagarsamy run the acceptance tests of SC, `When_a_custom_check_fails.Should_result_in_a_custom_check_failed_event` fails"}}