Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 718830a

Browse files
authored
Merge pull request #678 from github/fixes/repository-create-exception
Switch to main thread on repository creation.
2 parents 0265e86 + 0db5532 commit 718830a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/GitHub.App/GitHub.App.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
<HintPath>..\..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6070\lib\Microsoft.VisualStudio.TextManager.Interop.dll</HintPath>
7373
<Private>True</Private>
7474
</Reference>
75+
<Reference Include="Microsoft.VisualStudio.Threading, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
76+
<SpecificVersion>False</SpecificVersion>
77+
<HintPath>..\..\packages\Microsoft.VisualStudio.Threading.14.1.131\lib\net45\Microsoft.VisualStudio.Threading.dll</HintPath>
78+
</Reference>
7579
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
7680
<SpecificVersion>False</SpecificVersion>
7781
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>

src/GitHub.App/Services/RepositoryCloneService.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
using System.IO;
44
using System.Reactive;
55
using System.Reactive.Linq;
6-
using Rothko;
76
using GitHub.Extensions;
7+
using Microsoft.VisualStudio.Shell;
88
using NLog;
9+
using Rothko;
910

1011
namespace GitHub.Services
1112
{
@@ -39,12 +40,16 @@ public IObservable<Unit> CloneRepository(string cloneUrl, string repositoryName,
3940
Guard.ArgumentNotEmptyString(repositoryName, nameof(repositoryName));
4041
Guard.ArgumentNotEmptyString(repositoryPath, nameof(repositoryPath));
4142

42-
return Observable.Start(() =>
43+
return Observable.StartAsync(async () =>
4344
{
4445
string path = Path.Combine(repositoryPath, repositoryName);
4546

4647
operatingSystem.Directory.CreateDirectory(path);
4748

49+
// Once we've done IO switch to the main thread to call vsGitServices.Clone() as this must be
50+
// called on the main thread.
51+
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
52+
4853
try
4954
{
5055
// this will throw if it can't find it

0 commit comments

Comments
 (0)