I am creating a function that creates a point in specific coordinates, which calls itself moving to each of the cardinal points (until a spicific limit).
I have a StackOverflowException error when more than 5000 positions are stored.
More easy: I have created points with coordinates moving only to the north and still giving the same error
*NorthLimit, LatitudeDeviation and LongitudeDeviation are constants.
public void CreatePosition(decimal latitude, decimal longitude)
{
boolean end = true;
Positions.Add(new Position(latitude, longitude));
if (NorthLimit > (latitude + LatitudeDeviation))
{
CreatePosition(latitude + LatitudeDeviation, longitude);
end = false;
}
if (end == true)
{
// It ends :)
}
}
What measures should I take?