Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. private bool aborted = false;
  2.  
  3. public ResultClass Method()
  4. {
  5. for (i = 0; i < int.MaxValue && !aborted; i++)
  6. {
  7. // ...
  8. }
  9.  
  10. if (aborted)
  11. {
  12. return null;
  13. }
  14.  
  15. return new ResultClass(...);
  16. }
  17.  
  18. public void Abort()
  19. {
  20. aborted = true;
  21. }
  22.  
  23. try {
  24. // abortable code
  25. }
  26. finally
  27. {
  28. // clean-up resources
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement