-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConfiguredProject-level service for determining whether a project is implicitly active #3060
Conversation
Handles the case when the CancellationToken has already been been disposed.
Let's configured-project services await on becoming active.
When the project unloads while we're getting a call back, we reset the cancellation token to inactive state.
tag @dotnet/project-system ready for review. |
namespace Microsoft.VisualStudio.ProjectSystem | ||
{ | ||
/// <summary> | ||
/// Provides properties and events to track the implicit activation of an <see cref="ConfiguredProject"/>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: an ConfiguredProject.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/// </summary> | ||
internal static class CancellationTokenExtensions | ||
{ | ||
#pragma warning disable CA1068 // CancellationToken parameters must come last |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider filing a bug to not fire this if the CancellationToken
is a this
parameter to an extension method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private void OnImplicitlyDeactivated() | ||
{ | ||
_isImplicitlyActiveSource = new TaskCompletionSource<object>(); | ||
Thread.MemoryBarrier(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you comment why this is required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{ | ||
EnsureInitialized(true); | ||
|
||
_version++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to be called from multiple threads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is test code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a new ConfiguredProject-level service that allows services that live within that scope to "await" on being active:
The current API shape matches that needed by
ConfiguredProjectReadyToBuild
. It will be extended to support "startup and shutdown" scenarios needed by the language service.Events that enable startup and shutdown scenarios(Will do in a future check-in)