Heuristic Unreachable code

Hi

I have a lot of "heuristic unreachable code" which can be reached.

Its quite easy to reproduce.

On KeyPress a variable is set (Lets call it abort)

if (abort)
   return;
 DoSomethingLongRunning();

 if (abort)
   return; //>- yup. Resharper detects this as unreachable. However if the key is pressed during the first long running thing it stops definitly
DoSomethingElseLongRunning();

How can such false detection be avoided?

Please sign in to leave a comment.