{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls/comments/73397902","id":73397902,"diff_hunk":"@@ -0,0 +1,173 @@\n+namespace Microsoft.ApplicationInsights\n+{\n+    using System;\n+    using System.Threading;\n+    using System.Threading.Tasks;\n+    using Microsoft.VisualStudio.TestTools.UnitTesting;\n+    using Assert = Xunit.Assert;\n+\n+    [TestClass]\n+    public class TaskExTests\n+    {\n+\n+        [TestMethod]\n+        public void RethrowIfFailedDoesntThrowIfNoExceptionOccured()\n+        {\n+            var task = Task.Factory.StartNew(() => { });\n+\n+            task.Wait();\n+\n+            Assert.DoesNotThrow(() => task.RethrowIfFailed());\n+        }\n+\n+        [TestMethod]\n+        public void RethrowIfFailedThrowsIfTaskIsNotCompleted()\n+        {\n+            var task = TaskEx.Delay(TimeSpan.FromMilliseconds(100));\n+\n+            Assert.Throws<ArgumentException>(() => task.RethrowIfFailed());\n+        }\n+\n+        [TestMethod]\n+        public void RethrowIfFailedThrowsIfExceptionOccured()\n+        {\n+            var task = Task.Factory.StartNew(() => { throw new Exception(); });\n+\n+            try\n+            {\n+                task.Wait();\n+            }\n+            catch (Exception)\n+            {\n+                // ignore\n+            }\n+\n+            Assert.Throws<AggregateException>(() => task.RethrowIfFailed());\n+        }\n+\n+        [TestMethod]\n+        public void DelayWithZeroTimeoutCompletesTask()\n+        {\n+            var task = TaskEx.Delay(TimeSpan.Zero);\n+            task.Wait();\n+\n+            Assert.Equal(task.Status, TaskStatus.RanToCompletion);\n+        }\n+\n+        [TestMethod]\n+        public void DelayWaitsAtLeastTimeout()\n+        {\n+            var timeout = TimeSpan.FromMilliseconds(50);\n+            var time = DateTime.UtcNow;\n+            var task = TaskEx.Delay(timeout);\n+            \n+            task.Wait();\n+            var spent = DateTime.UtcNow - time;\n+\n+            Assert.True(spent >= timeout);\n+        }\n+\n+        [TestMethod]\n+        public void DelayWhichIsCanceledThrows()\n+        {\n+            var timeout = TimeSpan.FromSeconds(1);\n+            var cancellationTokenSource = new CancellationTokenSource();\n+            var task = TaskEx.Delay(timeout, cancellationTokenSource.Token);\n+\n+            cancellationTokenSource.Cancel();\n+\n+            Assert.Throws<AggregateException>(() => task.Wait());\n+        }\n+\n+        [TestMethod]\n+        public void DelayWith1SecondAndCanceledDoesntWaitForASecond()\n+        {\n+            var timeout = TimeSpan.FromSeconds(1);\n+            var cancellationTokenSource = new CancellationTokenSource();\n+            var task = TaskEx.Delay(timeout, cancellationTokenSource.Token);\n+\n+            var time = DateTime.UtcNow;\n+            var cancelTimeout = TimeSpan.FromMilliseconds(50);\n+            TaskEx.Delay(cancelTimeout).ContinueWith(task1 => cancellationTokenSource.Cancel());\n+            try\n+            {\n+                task.Wait();\n+            }\n+            catch (Exception)\n+            {\n+                // ignore\n+            }\n+            var spent = DateTime.UtcNow - time;\n+\n+            Assert.True(spent >= cancelTimeout && spent < timeout);","path":"Test/CoreSDK.Test/Net40/TaskExTests.cs","position":102,"original_position":102,"commit_id":"f7776ae5a63b3ed7b222675c07cabeb655c72081","original_commit_id":"f7776ae5a63b3ed7b222675c07cabeb655c72081","user":{"login":"dnduffy","id":17888193,"avatar_url":"https://avatars.githubusercontent.com/u/17888193?v=3","gravatar_id":"","url":"https://api.github.com/users/dnduffy","html_url":"https://github.com/dnduffy","followers_url":"https://api.github.com/users/dnduffy/followers","following_url":"https://api.github.com/users/dnduffy/following{/other_user}","gists_url":"https://api.github.com/users/dnduffy/gists{/gist_id}","starred_url":"https://api.github.com/users/dnduffy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnduffy/subscriptions","organizations_url":"https://api.github.com/users/dnduffy/orgs","repos_url":"https://api.github.com/users/dnduffy/repos","events_url":"https://api.github.com/users/dnduffy/events{/privacy}","received_events_url":"https://api.github.com/users/dnduffy/received_events","type":"User","site_admin":false},"body":"It's probably safe enough for the test but just FYI this is technically a form of race condition that could fail in an edge case situation of high CPU load.","created_at":"2016-08-03T18:52:57Z","updated_at":"2016-08-03T18:52:57Z","html_url":"https://github.com/Microsoft/ApplicationInsights-dotnet/pull/267#discussion_r73397902","pull_request_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls/267","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls/comments/73397902"},"html":{"href":"https://github.com/Microsoft/ApplicationInsights-dotnet/pull/267#discussion_r73397902"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls/267"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls/267","id":79514278,"html_url":"https://github.com/Microsoft/ApplicationInsights-dotnet/pull/267","diff_url":"https://github.com/Microsoft/ApplicationInsights-dotnet/pull/267.diff","patch_url":"https://github.com/Microsoft/ApplicationInsights-dotnet/pull/267.patch","issue_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/issues/267","number":267,"state":"open","locked":false,"title":"Issue 175, no BCL references for .Net40","user":{"login":"ki0ki0","id":1998334,"avatar_url":"https://avatars.githubusercontent.com/u/1998334?v=3","gravatar_id":"","url":"https://api.github.com/users/ki0ki0","html_url":"https://github.com/ki0ki0","followers_url":"https://api.github.com/users/ki0ki0/followers","following_url":"https://api.github.com/users/ki0ki0/following{/other_user}","gists_url":"https://api.github.com/users/ki0ki0/gists{/gist_id}","starred_url":"https://api.github.com/users/ki0ki0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ki0ki0/subscriptions","organizations_url":"https://api.github.com/users/ki0ki0/orgs","repos_url":"https://api.github.com/users/ki0ki0/repos","events_url":"https://api.github.com/users/ki0ki0/events{/privacy}","received_events_url":"https://api.github.com/users/ki0ki0/received_events","type":"User","site_admin":false},"body":"BCL dependencies has been removed from base API project.\r\nTelemetryChannel still uses BCL.\r\n\r\n[Issue 175](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/175)","created_at":"2016-08-01T05:17:29Z","updated_at":"2016-08-03T18:52:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9175f0de6988060b858a42769d9b09739015f413","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls/267/commits","review_comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls/267/comments","review_comment_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/issues/267/comments","statuses_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/statuses/f7776ae5a63b3ed7b222675c07cabeb655c72081","head":{"label":"ZeoAlliance:issue-175-NoBCL_pull","ref":"issue-175-NoBCL_pull","sha":"f7776ae5a63b3ed7b222675c07cabeb655c72081","user":{"login":"ZeoAlliance","id":7923032,"avatar_url":"https://avatars.githubusercontent.com/u/7923032?v=3","gravatar_id":"","url":"https://api.github.com/users/ZeoAlliance","html_url":"https://github.com/ZeoAlliance","followers_url":"https://api.github.com/users/ZeoAlliance/followers","following_url":"https://api.github.com/users/ZeoAlliance/following{/other_user}","gists_url":"https://api.github.com/users/ZeoAlliance/gists{/gist_id}","starred_url":"https://api.github.com/users/ZeoAlliance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZeoAlliance/subscriptions","organizations_url":"https://api.github.com/users/ZeoAlliance/orgs","repos_url":"https://api.github.com/users/ZeoAlliance/repos","events_url":"https://api.github.com/users/ZeoAlliance/events{/privacy}","received_events_url":"https://api.github.com/users/ZeoAlliance/received_events","type":"Organization","site_admin":false},"repo":{"id":63170193,"name":"ApplicationInsights-dotnet","full_name":"ZeoAlliance/ApplicationInsights-dotnet","owner":{"login":"ZeoAlliance","id":7923032,"avatar_url":"https://avatars.githubusercontent.com/u/7923032?v=3","gravatar_id":"","url":"https://api.github.com/users/ZeoAlliance","html_url":"https://github.com/ZeoAlliance","followers_url":"https://api.github.com/users/ZeoAlliance/followers","following_url":"https://api.github.com/users/ZeoAlliance/following{/other_user}","gists_url":"https://api.github.com/users/ZeoAlliance/gists{/gist_id}","starred_url":"https://api.github.com/users/ZeoAlliance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZeoAlliance/subscriptions","organizations_url":"https://api.github.com/users/ZeoAlliance/orgs","repos_url":"https://api.github.com/users/ZeoAlliance/repos","events_url":"https://api.github.com/users/ZeoAlliance/events{/privacy}","received_events_url":"https://api.github.com/users/ZeoAlliance/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ZeoAlliance/ApplicationInsights-dotnet","description":"ApplicationInsights-dotnet","fork":true,"url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet","forks_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/forks","keys_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/teams","hooks_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/hooks","issue_events_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/issues/events{/number}","events_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/events","assignees_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/assignees{/user}","branches_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/branches{/branch}","tags_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/tags","blobs_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/statuses/{sha}","languages_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/languages","stargazers_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/stargazers","contributors_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/contributors","subscribers_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/subscribers","subscription_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/subscription","commits_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/contents/{+path}","compare_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/merges","archive_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/downloads","issues_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/issues{/number}","pulls_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/pulls{/number}","milestones_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/milestones{/number}","notifications_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/labels{/name}","releases_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/releases{/id}","deployments_url":"https://api.github.com/repos/ZeoAlliance/ApplicationInsights-dotnet/deployments","created_at":"2016-07-12T15:34:42Z","updated_at":"2016-07-12T15:34:44Z","pushed_at":"2016-08-01T05:10:25Z","git_url":"git://github.com/ZeoAlliance/ApplicationInsights-dotnet.git","ssh_url":"git@github.com:ZeoAlliance/ApplicationInsights-dotnet.git","clone_url":"https://github.com/ZeoAlliance/ApplicationInsights-dotnet.git","svn_url":"https://github.com/ZeoAlliance/ApplicationInsights-dotnet","homepage":null,"size":3504,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Microsoft:develop","ref":"develop","sha":"4d51cc1dd1b9f7fc10dd02d0c026a2783c215504","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":37284654,"name":"ApplicationInsights-dotnet","full_name":"Microsoft/ApplicationInsights-dotnet","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/ApplicationInsights-dotnet","description":"ApplicationInsights-dotnet","fork":false,"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet","forks_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/forks","keys_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/teams","hooks_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/events","assignees_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/tags","blobs_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/languages","stargazers_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/subscription","commits_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/merges","archive_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/downloads","issues_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/deployments","created_at":"2015-06-11T20:34:21Z","updated_at":"2016-07-26T08:20:42Z","pushed_at":"2016-08-01T05:17:30Z","git_url":"git://github.com/Microsoft/ApplicationInsights-dotnet.git","ssh_url":"git@github.com:Microsoft/ApplicationInsights-dotnet.git","clone_url":"https://github.com/Microsoft/ApplicationInsights-dotnet.git","svn_url":"https://github.com/Microsoft/ApplicationInsights-dotnet","homepage":null,"size":4267,"stargazers_count":62,"watchers_count":62,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":16,"forks":35,"open_issues":16,"watchers":62,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls/267"},"html":{"href":"https://github.com/Microsoft/ApplicationInsights-dotnet/pull/267"},"issue":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/issues/267"},"comments":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/issues/267/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls/267/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/pulls/267/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/ApplicationInsights-dotnet/statuses/f7776ae5a63b3ed7b222675c07cabeb655c72081"}}}}
{"actor":{"display_login":"dnduffy"}}