{"action":"created","comment":{"url":"https://api.github.com/repos/gitextensions/gitextensions/pulls/comments/178473343","pull_request_review_id":108533610,"id":178473343,"diff_hunk":"@@ -1,96 +1,141 @@\n ﻿using System;\n using System.Collections.Generic;\n using System.Linq;\n+using System.Text;\n+using System.Threading;\n+using System.Threading.Tasks;\n+using System.Windows.Forms;\n using GitCommands;\n using GitCommands.Statistics;\n+using Microsoft.VisualStudio.Threading;\n \n namespace GitUI.CommandsDialogs.BrowseDialog\n {\n     public partial class FormCommitCount : GitModuleForm\n     {\n+        private CancellationTokenSource _backgroundLoaderTokenSource = new CancellationTokenSource();\n+\n         public FormCommitCount(GitUICommands commands)\n             : base(commands)\n         {\n             InitializeComponent();\n             Loading.Image = Properties.Resources.loadingpanel;\n             Translate();\n-        }\n \n-        private void FormCommitCountLoad(object sender, EventArgs e)\n-        {\n-            FetchData();\n+            Load += delegate { FetchData(); };\n+            cbIncludeSubmodules.CheckedChanged += delegate { FetchData(); };\n         }\n \n-        private void cbIncludeSubmodules_CheckedChanged(object sender, EventArgs e)\n+        private void FetchData()\n         {\n-            FetchData();\n+            ThreadHelper.ThrowIfNotOnUIThread();\n+\n+            _backgroundLoaderTokenSource.Cancel();\n+            _backgroundLoaderTokenSource.Dispose();\n+            _backgroundLoaderTokenSource = new CancellationTokenSource();\n+            var token = _backgroundLoaderTokenSource.Token;\n+\n+            ThreadHelper.JoinableTaskFactory.RunAsync(\n+                async () =>\n+                {\n+                    Loading.Visible = true;\n+\n+                    CommitCount.Text = \"\";\n+\n+                    var includeSubmodules = cbIncludeSubmodules.Checked;\n+\n+                    await TaskScheduler.Default;\n+\n+                    var text = GenerateText(Module, includeSubmodules, token);","path":"GitUI/CommandsDialogs/BrowseDialog/FormCommitCount.cs","position":55,"original_position":55,"commit_id":"11da82ff9e6315e24052f49ca10ebd4fdc7a4790","original_commit_id":"11da82ff9e6315e24052f49ca10ebd4fdc7a4790","user":{"login":"RussKie","id":4403806,"avatar_url":"https://avatars3.githubusercontent.com/u/4403806?v=4","gravatar_id":"","url":"https://api.github.com/users/RussKie","html_url":"https://github.com/RussKie","followers_url":"https://api.github.com/users/RussKie/followers","following_url":"https://api.github.com/users/RussKie/following{/other_user}","gists_url":"https://api.github.com/users/RussKie/gists{/gist_id}","starred_url":"https://api.github.com/users/RussKie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RussKie/subscriptions","organizations_url":"https://api.github.com/users/RussKie/orgs","repos_url":"https://api.github.com/users/RussKie/repos","events_url":"https://api.github.com/users/RussKie/events{/privacy}","received_events_url":"https://api.github.com/users/RussKie/received_events","type":"User","site_admin":false},"body":"Yes, you're right.\r\nThis is one of those inconsistencies we need to address across the codebase","created_at":"2018-04-02T00:42:37Z","updated_at":"2018-04-02T00:42:38Z","html_url":"https://github.com/gitextensions/gitextensions/pull/4742#discussion_r178473343","pull_request_url":"https://api.github.com/repos/gitextensions/gitextensions/pulls/4742","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/gitextensions/gitextensions/pulls/comments/178473343"},"html":{"href":"https://github.com/gitextensions/gitextensions/pull/4742#discussion_r178473343"},"pull_request":{"href":"https://api.github.com/repos/gitextensions/gitextensions/pulls/4742"}},"in_reply_to_id":178470871},"pull_request":{"url":"https://api.github.com/repos/gitextensions/gitextensions/pulls/4742","id":178697481,"html_url":"https://github.com/gitextensions/gitextensions/pull/4742","diff_url":"https://github.com/gitextensions/gitextensions/pull/4742.diff","patch_url":"https://github.com/gitextensions/gitextensions/pull/4742.patch","issue_url":"https://api.github.com/repos/gitextensions/gitextensions/issues/4742","number":4742,"state":"open","locked":false,"title":"FormCommitCount doesn't block UI thread","user":{"login":"drewnoakes","id":350947,"avatar_url":"https://avatars2.githubusercontent.com/u/350947?v=4","gravatar_id":"","url":"https://api.github.com/users/drewnoakes","html_url":"https://github.com/drewnoakes","followers_url":"https://api.github.com/users/drewnoakes/followers","following_url":"https://api.github.com/users/drewnoakes/following{/other_user}","gists_url":"https://api.github.com/users/drewnoakes/gists{/gist_id}","starred_url":"https://api.github.com/users/drewnoakes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drewnoakes/subscriptions","organizations_url":"https://api.github.com/users/drewnoakes/orgs","repos_url":"https://api.github.com/users/drewnoakes/repos","events_url":"https://api.github.com/users/drewnoakes/events{/privacy}","received_events_url":"https://api.github.com/users/drewnoakes/received_events","type":"User","site_admin":false},"body":"Wanted to make a simple conversion using the new VS Threading stuff. It's nothing too exciting, but was satisfying to see how straightforward such a change was.\r\n\r\nI actually did this a while back and it was the precursor to the ideas in #4735. \r\n\r\nChanges proposed in this pull request:\r\n - Query statistics and compose text on a background thread\r\n - Optimise string composition (many fewer allocations)\r\n \r\nWhat did I do to test the code and ensure quality:\r\n - Lots of manual testing\r\n\r\nHas been tested on:\r\n - GIT 2.16\r\n - Windows 10\r\n","created_at":"2018-03-31T19:45:07Z","updated_at":"2018-04-02T00:42:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"353818497e4b98e5b7ecf6fcd0909bc3057e739e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/gitextensions/gitextensions/pulls/4742/commits","review_comments_url":"https://api.github.com/repos/gitextensions/gitextensions/pulls/4742/comments","review_comment_url":"https://api.github.com/repos/gitextensions/gitextensions/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gitextensions/gitextensions/issues/4742/comments","statuses_url":"https://api.github.com/repos/gitextensions/gitextensions/statuses/11da82ff9e6315e24052f49ca10ebd4fdc7a4790","head":{"label":"drewnoakes:form-commit-count","ref":"form-commit-count","sha":"11da82ff9e6315e24052f49ca10ebd4fdc7a4790","user":{"login":"drewnoakes","id":350947,"avatar_url":"https://avatars2.githubusercontent.com/u/350947?v=4","gravatar_id":"","url":"https://api.github.com/users/drewnoakes","html_url":"https://github.com/drewnoakes","followers_url":"https://api.github.com/users/drewnoakes/followers","following_url":"https://api.github.com/users/drewnoakes/following{/other_user}","gists_url":"https://api.github.com/users/drewnoakes/gists{/gist_id}","starred_url":"https://api.github.com/users/drewnoakes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drewnoakes/subscriptions","organizations_url":"https://api.github.com/users/drewnoakes/orgs","repos_url":"https://api.github.com/users/drewnoakes/repos","events_url":"https://api.github.com/users/drewnoakes/events{/privacy}","received_events_url":"https://api.github.com/users/drewnoakes/received_events","type":"User","site_admin":false},"repo":{"id":121311835,"name":"gitextensions","full_name":"drewnoakes/gitextensions","owner":{"login":"drewnoakes","id":350947,"avatar_url":"https://avatars2.githubusercontent.com/u/350947?v=4","gravatar_id":"","url":"https://api.github.com/users/drewnoakes","html_url":"https://github.com/drewnoakes","followers_url":"https://api.github.com/users/drewnoakes/followers","following_url":"https://api.github.com/users/drewnoakes/following{/other_user}","gists_url":"https://api.github.com/users/drewnoakes/gists{/gist_id}","starred_url":"https://api.github.com/users/drewnoakes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drewnoakes/subscriptions","organizations_url":"https://api.github.com/users/drewnoakes/orgs","repos_url":"https://api.github.com/users/drewnoakes/repos","events_url":"https://api.github.com/users/drewnoakes/events{/privacy}","received_events_url":"https://api.github.com/users/drewnoakes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/drewnoakes/gitextensions","description":"Git Extensions is a standalone UI tool for managing git repositories. It also integrates with Windows Explorer and Microsoft Visual Studio (2010/2012/2013/2015/2017).","fork":true,"url":"https://api.github.com/repos/drewnoakes/gitextensions","forks_url":"https://api.github.com/repos/drewnoakes/gitextensions/forks","keys_url":"https://api.github.com/repos/drewnoakes/gitextensions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/drewnoakes/gitextensions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/drewnoakes/gitextensions/teams","hooks_url":"https://api.github.com/repos/drewnoakes/gitextensions/hooks","issue_events_url":"https://api.github.com/repos/drewnoakes/gitextensions/issues/events{/number}","events_url":"https://api.github.com/repos/drewnoakes/gitextensions/events","assignees_url":"https://api.github.com/repos/drewnoakes/gitextensions/assignees{/user}","branches_url":"https://api.github.com/repos/drewnoakes/gitextensions/branches{/branch}","tags_url":"https://api.github.com/repos/drewnoakes/gitextensions/tags","blobs_url":"https://api.github.com/repos/drewnoakes/gitextensions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/drewnoakes/gitextensions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/drewnoakes/gitextensions/git/refs{/sha}","trees_url":"https://api.github.com/repos/drewnoakes/gitextensions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/drewnoakes/gitextensions/statuses/{sha}","languages_url":"https://api.github.com/repos/drewnoakes/gitextensions/languages","stargazers_url":"https://api.github.com/repos/drewnoakes/gitextensions/stargazers","contributors_url":"https://api.github.com/repos/drewnoakes/gitextensions/contributors","subscribers_url":"https://api.github.com/repos/drewnoakes/gitextensions/subscribers","subscription_url":"https://api.github.com/repos/drewnoakes/gitextensions/subscription","commits_url":"https://api.github.com/repos/drewnoakes/gitextensions/commits{/sha}","git_commits_url":"https://api.github.com/repos/drewnoakes/gitextensions/git/commits{/sha}","comments_url":"https://api.github.com/repos/drewnoakes/gitextensions/comments{/number}","issue_comment_url":"https://api.github.com/repos/drewnoakes/gitextensions/issues/comments{/number}","contents_url":"https://api.github.com/repos/drewnoakes/gitextensions/contents/{+path}","compare_url":"https://api.github.com/repos/drewnoakes/gitextensions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/drewnoakes/gitextensions/merges","archive_url":"https://api.github.com/repos/drewnoakes/gitextensions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/drewnoakes/gitextensions/downloads","issues_url":"https://api.github.com/repos/drewnoakes/gitextensions/issues{/number}","pulls_url":"https://api.github.com/repos/drewnoakes/gitextensions/pulls{/number}","milestones_url":"https://api.github.com/repos/drewnoakes/gitextensions/milestones{/number}","notifications_url":"https://api.github.com/repos/drewnoakes/gitextensions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/drewnoakes/gitextensions/labels{/name}","releases_url":"https://api.github.com/repos/drewnoakes/gitextensions/releases{/id}","deployments_url":"https://api.github.com/repos/drewnoakes/gitextensions/deployments","created_at":"2018-02-12T22:42:24Z","updated_at":"2018-03-29T21:54:05Z","pushed_at":"2018-04-01T12:13:38Z","git_url":"git://github.com/drewnoakes/gitextensions.git","ssh_url":"git@github.com:drewnoakes/gitextensions.git","clone_url":"https://github.com/drewnoakes/gitextensions.git","svn_url":"https://github.com/drewnoakes/gitextensions","homepage":"http://gitextensions.github.io/","size":73232,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gitextensions:master","ref":"master","sha":"22709a79dc2f63aeed67870c2f2dae31b9cceaad","user":{"login":"gitextensions","id":1700077,"avatar_url":"https://avatars2.githubusercontent.com/u/1700077?v=4","gravatar_id":"","url":"https://api.github.com/users/gitextensions","html_url":"https://github.com/gitextensions","followers_url":"https://api.github.com/users/gitextensions/followers","following_url":"https://api.github.com/users/gitextensions/following{/other_user}","gists_url":"https://api.github.com/users/gitextensions/gists{/gist_id}","starred_url":"https://api.github.com/users/gitextensions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitextensions/subscriptions","organizations_url":"https://api.github.com/users/gitextensions/orgs","repos_url":"https://api.github.com/users/gitextensions/repos","events_url":"https://api.github.com/users/gitextensions/events{/privacy}","received_events_url":"https://api.github.com/users/gitextensions/received_events","type":"Organization","site_admin":false},"repo":{"id":85953,"name":"gitextensions","full_name":"gitextensions/gitextensions","owner":{"login":"gitextensions","id":1700077,"avatar_url":"https://avatars2.githubusercontent.com/u/1700077?v=4","gravatar_id":"","url":"https://api.github.com/users/gitextensions","html_url":"https://github.com/gitextensions","followers_url":"https://api.github.com/users/gitextensions/followers","following_url":"https://api.github.com/users/gitextensions/following{/other_user}","gists_url":"https://api.github.com/users/gitextensions/gists{/gist_id}","starred_url":"https://api.github.com/users/gitextensions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitextensions/subscriptions","organizations_url":"https://api.github.com/users/gitextensions/orgs","repos_url":"https://api.github.com/users/gitextensions/repos","events_url":"https://api.github.com/users/gitextensions/events{/privacy}","received_events_url":"https://api.github.com/users/gitextensions/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gitextensions/gitextensions","description":"Git Extensions is a standalone UI tool for managing git repositories. It also integrates with Windows Explorer and Microsoft Visual Studio (2010/2012/2013/2015/2017).","fork":false,"url":"https://api.github.com/repos/gitextensions/gitextensions","forks_url":"https://api.github.com/repos/gitextensions/gitextensions/forks","keys_url":"https://api.github.com/repos/gitextensions/gitextensions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gitextensions/gitextensions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gitextensions/gitextensions/teams","hooks_url":"https://api.github.com/repos/gitextensions/gitextensions/hooks","issue_events_url":"https://api.github.com/repos/gitextensions/gitextensions/issues/events{/number}","events_url":"https://api.github.com/repos/gitextensions/gitextensions/events","assignees_url":"https://api.github.com/repos/gitextensions/gitextensions/assignees{/user}","branches_url":"https://api.github.com/repos/gitextensions/gitextensions/branches{/branch}","tags_url":"https://api.github.com/repos/gitextensions/gitextensions/tags","blobs_url":"https://api.github.com/repos/gitextensions/gitextensions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gitextensions/gitextensions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gitextensions/gitextensions/git/refs{/sha}","trees_url":"https://api.github.com/repos/gitextensions/gitextensions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gitextensions/gitextensions/statuses/{sha}","languages_url":"https://api.github.com/repos/gitextensions/gitextensions/languages","stargazers_url":"https://api.github.com/repos/gitextensions/gitextensions/stargazers","contributors_url":"https://api.github.com/repos/gitextensions/gitextensions/contributors","subscribers_url":"https://api.github.com/repos/gitextensions/gitextensions/subscribers","subscription_url":"https://api.github.com/repos/gitextensions/gitextensions/subscription","commits_url":"https://api.github.com/repos/gitextensions/gitextensions/commits{/sha}","git_commits_url":"https://api.github.com/repos/gitextensions/gitextensions/git/commits{/sha}","comments_url":"https://api.github.com/repos/gitextensions/gitextensions/comments{/number}","issue_comment_url":"https://api.github.com/repos/gitextensions/gitextensions/issues/comments{/number}","contents_url":"https://api.github.com/repos/gitextensions/gitextensions/contents/{+path}","compare_url":"https://api.github.com/repos/gitextensions/gitextensions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gitextensions/gitextensions/merges","archive_url":"https://api.github.com/repos/gitextensions/gitextensions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gitextensions/gitextensions/downloads","issues_url":"https://api.github.com/repos/gitextensions/gitextensions/issues{/number}","pulls_url":"https://api.github.com/repos/gitextensions/gitextensions/pulls{/number}","milestones_url":"https://api.github.com/repos/gitextensions/gitextensions/milestones{/number}","notifications_url":"https://api.github.com/repos/gitextensions/gitextensions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gitextensions/gitextensions/labels{/name}","releases_url":"https://api.github.com/repos/gitextensions/gitextensions/releases{/id}","deployments_url":"https://api.github.com/repos/gitextensions/gitextensions/deployments","created_at":"2008-12-06T09:18:59Z","updated_at":"2018-04-02T00:29:54Z","pushed_at":"2018-04-01T23:16:50Z","git_url":"git://github.com/gitextensions/gitextensions.git","ssh_url":"git@github.com:gitextensions/gitextensions.git","clone_url":"https://github.com/gitextensions/gitextensions.git","svn_url":"https://github.com/gitextensions/gitextensions","homepage":"http://gitextensions.github.io/","size":72651,"stargazers_count":2710,"watchers_count":2710,"language":"C#","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":976,"mirror_url":null,"archived":false,"open_issues_count":682,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":976,"open_issues":682,"watchers":2710,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gitextensions/gitextensions/pulls/4742"},"html":{"href":"https://github.com/gitextensions/gitextensions/pull/4742"},"issue":{"href":"https://api.github.com/repos/gitextensions/gitextensions/issues/4742"},"comments":{"href":"https://api.github.com/repos/gitextensions/gitextensions/issues/4742/comments"},"review_comments":{"href":"https://api.github.com/repos/gitextensions/gitextensions/pulls/4742/comments"},"review_comment":{"href":"https://api.github.com/repos/gitextensions/gitextensions/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gitextensions/gitextensions/pulls/4742/commits"},"statuses":{"href":"https://api.github.com/repos/gitextensions/gitextensions/statuses/11da82ff9e6315e24052f49ca10ebd4fdc7a4790"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"RussKie"}}