I'm looking for some more info/inspiration and was wondering if there is a pattern for the following.
Now and then I have something that should not be an infinite loop, but CAN be an infinite loop if a bug is introduced.
As it is in a Web Application I rather have it to throw an exception if we more or less know it hangs instead of a thread getting stuck and slowly depleting all resources.
Some similar code below, it's not about the details.
Is there a name for this pattern or any other words for looking up more thoughts about this?
while ( _Combinations.Any() )
{
var combination = _Combinations.First();
combination.New.DuplicateIndex = combination.Current.DuplicateIndex;
RemoveAllFromCombinations(combination.New);
if ( emergency_break++ > 10_000 )
throw new ArgumentException("More loops then expected - crash instead of hang");
}
Aucun commentaire:
Enregistrer un commentaire