提交 de1e0ade 编写于 作者: S Sam Harwell

Gate the access to _tokenSource

上级 bbb96d00
......@@ -127,7 +127,14 @@ internal partial class PackageInstallerService : AbstractDelayStartedService, IP
private async Task<ImmutableArray<PackageSource>?> GetPackageSourcesImplAsync()
{
var cancellationToken = _tokenSource.Token;
CancellationToken cancellationToken;
lock (_gate)
{
// Read the current cancellation token within the gate to ensure the token source is not disposed at the
// time of the read.
cancellationToken = _tokenSource.Token;
}
try
{
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册