Skip to content

IComponentContext.IsConnected usage clarification #13741

@kevinjpetersen

Description

@kevinjpetersen

Is your feature request related to a problem? Please describe.

It seems something hasn't been clarified in the latest blog post with Preview 9. The removal of IComponentContext means you can no longer check if the Client is connected on the server side. Currently I use IComponentContext.IsConnected on a new Task that I create, and I want to stop this Task if the client is no longer connected.

protected override async Task OnInitializedAsync()
{
	await Task.Factory.StartNew(async () =>
	{
		while(true) {
			if (!ComponentContext.IsConnected)
			{
				Console.WriteLine("Client is no longer connected, stop task!");
				break;
			}
			Task.Delay(5000);
		}
	});
}

How can I replicate this functionality now that this is removed? Is it simply not possible anymore? If this cannot be replicated anymore, how would I be able to have a background task for a client that automatically stops/destroys itself when the client disconnects/closes their browser?

Describe the solution you'd like

Add a way to still use this functionality to check if the client is connected on the server side, or maybe create a new class of type Task, that automatically destroys itself when the client is no longer connected/disconnected etc.

Additional context

No further info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions