I have a block of C# code that contains a try/catch when connecting a client to a server using SignalR. My issue is that if I try to handle AggregateException
using Microsoft's example here I end up with an infinite loop of AggregateException
being thrown and caught even though I am thinking they shouldn't be.
My code looks just like Microsofts:
Connection = new HubConnection(Url);
Hub = Connection.CreateHubProxy(HubProxy);
try
{
Connection.Start().Wait();
}
catch (AggregateException aggEx)
{
foreach (var e in aggEx.InnerExceptions)
{
if (e is SocketException)
{
Console.WriteLine(e.ToString());
}
else
{
throw;
}
}
}
What would cause this to happen?