Share via


ConnectedServiceGrid.CreateServiceInstanceAsync(CancellationToken) Method

Definition

Create a new instance of the service.

public:
 virtual System::Threading::Tasks::Task<Microsoft::VisualStudio::ConnectedServices::ConnectedServiceInstance ^> ^ CreateServiceInstanceAsync(System::Threading::CancellationToken ct);
public virtual System.Threading.Tasks.Task<Microsoft.VisualStudio.ConnectedServices.ConnectedServiceInstance> CreateServiceInstanceAsync (System.Threading.CancellationToken ct);
abstract member CreateServiceInstanceAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.VisualStudio.ConnectedServices.ConnectedServiceInstance>
override this.CreateServiceInstanceAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.VisualStudio.ConnectedServices.ConnectedServiceInstance>
Public Overridable Function CreateServiceInstanceAsync (ct As CancellationToken) As Task(Of ConnectedServiceInstance)

Parameters

ct
CancellationToken

CancellationToken used to cancel the creation operation.

Returns

Returns a Task that provides the new service instance.

Remarks

This method is guaranteed to be called from the UI thread, and only on providers that return 'true' from IsAuthenticated if a ConnectedServiceAuthenticator is implemented.

If an implementation desires to present blocking/modal UI, it may do so. If the service instance is created synchronously before the method returns, the returned Task should be marked as completed (likely via Task.FromResult()).

If the implementation runs in the background, it may return an in-progress Task, and the Connected Services code will refresh the UI once the Task completes. In this case, the Connected Services code may cancel the task via the CancellationToken if the user closes the Conencted Services UI before the instance has been created.

If the implementation does not or cannot monitor the creation of the new instance, it may return null. In this case, the Connected Services code will do nothing, and requires the user to manually refresh/enumerate the service instances to check for the newly- created instance.

If the implementation shows/handles any errors, the Task should not fault on them, nor throw them as Exceptions. If the returned Task completes in a Faulted state (such that the Exception member is non-null) the Connected Services UI will inform the user of the failure.

Applies to