Class JoinableTaskCollection
- Namespace
- Microsoft.VisualStudio.Threading
- Assembly
- Microsoft.VisualStudio.Threading.dll
A collection of incomplete JoinableTask objects.
public class JoinableTaskCollection : IEnumerable<JoinableTask>, IEnumerable
- Inheritance
-
JoinableTaskCollection
- Implements
- Inherited Members
Remarks
Any completed JoinableTask is automatically removed from the collection.
Constructors
JoinableTaskCollection(JoinableTaskContext, bool)
Initializes a new instance of the JoinableTaskCollection class.
public JoinableTaskCollection(JoinableTaskContext context, bool refCountAddedJobs = false)
Parameters
context
JoinableTaskContextThe JoinableTaskContext instance to which this collection applies.
refCountAddedJobs
booltrue if JoinableTask instances added to the collection multiple times should remain in the collection until they are either removed the same number of times or until they are completed; false causes the first Remove call for a JoinableTask to remove it from this collection regardless how many times it had been added.
Properties
Context
Gets the JoinableTaskContext to which this collection belongs.
public JoinableTaskContext Context { get; }
Property Value
DisplayName
Gets or sets a human-readable name that may appear in hang reports.
public string? DisplayName { get; set; }
Property Value
Remarks
This property should not be set to a value that may disclose personally identifiable information or other confidential data since this value may be included in hang reports sent to a third party.
Methods
Add(JoinableTask)
Adds the specified JoinableTask to this collection.
public void Add(JoinableTask joinableTask)
Parameters
joinableTask
JoinableTaskThe JoinableTask to add to the collection.
Remarks
As the collection only stores incomplete JoinableTask instances,
if the joinableTask
is already completed, it will not be added to the collection and this method will simply return.
Any JoinableTask instances added to the collection will be automatically removed upon completion.
Contains(JoinableTask)
Checks whether the specified joinable task is a member of this collection.
public bool Contains(JoinableTask joinableTask)
Parameters
joinableTask
JoinableTask
Returns
GetEnumerator()
Enumerates the tasks in this collection.
public IEnumerator<JoinableTask> GetEnumerator()
Returns
Join()
Shares access to the main thread that the caller's JoinableTask may have (if any) with all JoinableTask instances in this collection until the returned value is disposed.
public JoinableTaskCollection.JoinRelease Join()
Returns
- JoinableTaskCollection.JoinRelease
A value to dispose of to revert the join.
Remarks
Calling this method when the caller is not executing within a JoinableTask safely no-ops.
JoinTillEmptyAsync()
Joins the caller's context to this collection till the collection is empty.
public Task JoinTillEmptyAsync()
Returns
- Task
A task that completes when this collection is empty.
Remarks
Any exceptions thrown by the tasks in this collection are not propagated to the returned task.
JoinTillEmptyAsync(CancellationToken)
Joins the caller's context to this collection till the collection is empty.
public Task JoinTillEmptyAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task
A task that completes when this collection is empty, or is canceled when
cancellationToken
is canceled.
Remarks
Any exceptions thrown by the tasks in this collection are not propagated to the returned task.
Remove(JoinableTask)
Removes the specified JoinableTask from this collection, or decrements the ref count if this collection tracks that.
public void Remove(JoinableTask joinableTask)
Parameters
joinableTask
JoinableTaskThe JoinableTask to remove.
Remarks
Completed JoinableTask instances are automatically removed from the collection. Calling this method to remove them is not necessary.