Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

HubConnection.Closed Event

Definition

Namespace:
Microsoft.AspNetCore.SignalR.Client
Assembly:
Microsoft.AspNetCore.SignalR.Client.Core.dll
Package:
Microsoft.AspNetCore.SignalR.Client.Core v10.0.0
Package:
Microsoft.AspNetCore.SignalR.Client.Core v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.SignalR.Client.Core v1.0.0
Package:
Microsoft.AspNetCore.SignalR.Client.Core v1.1.0
Package:
Microsoft.AspNetCore.SignalR.Client.Core v3.0.3
Package:
Microsoft.AspNetCore.SignalR.Client.Core v3.1.18
Package:
Microsoft.AspNetCore.SignalR.Client.Core v5.0.9
Package:
Microsoft.AspNetCore.SignalR.Client.Core v6.0.6
Package:
Microsoft.AspNetCore.SignalR.Client.Core v7.0.5
Package:
Microsoft.AspNetCore.SignalR.Client.Core v8.0.19
Package:
Microsoft.AspNetCore.SignalR.Client.Core v9.0.8
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs
Source:
HubConnection.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Occurs when the connection is closed. The connection could be closed due to an error or due to either the server or client intentionally closing the connection without error.

public:
 event Func<Exception ^, System::Threading::Tasks::Task ^> ^ Closed;
public event Func<Exception?,System.Threading.Tasks.Task>? Closed;
public event Func<Exception,System.Threading.Tasks.Task> Closed;
member this.Closed : Func<Exception, System.Threading.Tasks.Task> 
Public Event Closed As Func(Of Exception, Task) 

Event Type

Examples

The following example attaches a handler to the Closed event, and checks the provided argument to determine if there was an error:

connection.Closed += (exception) =>
{
 if (exception == null)
 {
 Console.WriteLine("Connection closed without error.");
 }
 else
 {
 Console.WriteLine($"Connection closed due to an error: {exception}");
 }
};

Remarks

If this event was triggered from a connection error, the Exception that occurred will be passed in as the sole argument to this handler. If this event was triggered intentionally by either the client or server, then the argument will be null.

The Task result does not block HubConnection operations.

Applies to


Feedback

Was this page helpful?