i need to check condition constantly. Not in each loop iteration but also during time of function execution.
wth like this is not acceptable:
while(condition)
{
...
}
I need simply to abort function even ‘in the middle’ of progress when condition appears true.
Any ideas?
Assuming this is some kind of error handling assert condition – Take a look at .NET Code Contracts and the ContractInvariantMethod, there’s a good example here.
It allows you to define conditions that are not allowed to occur, and causes assert if it ever does at runtime.
The following is taken from the link. It enforces that balance can never be negative, otherwise an exception will occur.