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

Commit f77b2b0

Browse files
committed
Use JoinableTaskFactory to call UpdateSearchHost
Avoid using RxApp.MainThreadScheduler.
1 parent 13f7a0c commit f77b2b0

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

src/GitHub.VisualStudio/UI/GitHubPane.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,26 @@ public FrameworkElement View
5656
return pane?.WhenAnyValue(p => p.IsSearchEnabled, p => p.SearchQuery)
5757
?? Observable.Return(Tuple.Create<bool, string>(false, null));
5858
})
59-
.ObserveOn(RxApp.MainThreadScheduler)
60-
.Subscribe(x => UpdateSearchHost(x.Item1, x.Item2));
59+
.Subscribe(x => JoinableTaskFactory.Run(async () =>
60+
{
61+
await JoinableTaskFactory.SwitchToMainThreadAsync();
62+
UpdateSearchHost(x.Item1, x.Item2);
63+
}));
6164
}
6265
}
6366

64-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
65-
public GitHubPane() : base(null)
67+
public GitHubPane() : this(ThreadHelper.JoinableTaskContext)
68+
{
69+
}
70+
71+
[SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
72+
public GitHubPane(JoinableTaskContext joinableTaskContext)
6673
{
74+
joinableTaskContext = joinableTaskContext ?? new JoinableTaskContext();
75+
JoinableTaskCollection = joinableTaskContext.CreateCollection();
76+
JoinableTaskCollection.DisplayName = nameof(GitHubPane);
77+
JoinableTaskFactory = joinableTaskContext.CreateFactory(JoinableTaskCollection);
78+
6779
Caption = "GitHub";
6880
Content = contentPresenter = new ContentPresenter();
6981

@@ -213,5 +225,7 @@ public SearchQuery(string query)
213225

214226
public uint GetTokens(uint dwMaxTokens, IVsSearchToken[] rgpSearchTokens) => 0;
215227
}
216-
}
228+
229+
public JoinableTaskCollection JoinableTaskCollection { get; }
230+
JoinableTaskFactory JoinableTaskFactory { get; } }
217231
}

0 commit comments

Comments
 (0)