When I don't have a VPN connection to my office, I need to throw an exception that says you are not connected, and I am struggling to catch that exception.
Here is a screenshot:
When I don't have a VPN connection to my office, I need to throw an exception that says you are not connected, and I am struggling to catch that exception.
Here is a screenshot:
Not Sure if I get you completely - But your For loop runs 68 times (is that what you mean) and then the Exception is thrown. Which you want to be handled way before so that For Doesnt run. My Guess is that you have Entity Framework. So your code gets the Exception when it actually tries to connect to DB. May be try:
MyDbContext.Database.Exists(); before you run the Loop. See if that returns Bool or throws Exception since server unreachable.