So, this happened:
How is this possible within a try
-block?
How come it does not forward that to the catch
-block?
Edit:
It has been pointed out, that I might have recursion. I do, which I did not think would cause a problem.
The full method looks like this:
private static GeoCoordinate ChangeLocation(GeoCoordinate location)
{
var tmp = location;
var direction = new Random().Next(0, 359);
var distance = new Random().Next(0, 5);
//Calculate movement
var vertical = Math.Sin(direction) * distance; //Sinus relation shortened
var lastAngle = 180 - 90 - (direction % 90);
var horisontal = Math.Sin(lastAngle) * distance; //Sinus relation shortened
//Add movement to location
tmp.Latitude = location.Latitude + (vertical / 10000);
tmp.Longitude = location.Longitude + (horisontal / 10000);
//If new location is outside a specific area
if (!InsidePolygon(_siteCoordinates, tmp))
{
_recursiveCounter++;
//Ninja edit: @Leppie pointed out I was missing 'tmp =':
tmp = ChangeLocation(location); //Recursive move to calculate a new location
}
//Print the amount of recursive moves
if (_recursiveCounter != 0)
Console.WriteLine($"Counter: {_recursiveCounter}");
_recursiveCounter = 0;
return tmp;
}