Last active
January 2, 2016 14:09
-
-
Save EdGuiness/8315115 to your computer and use it in GitHub Desktop.
Use this code when you want to be sure it happens
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// Use this to make sure A is set | |
| /// </summary> | |
| public int A | |
| { | |
| set | |
| { | |
| try | |
| { | |
| lock (lockObj) | |
| { | |
| a = value; // try it | |
| a = value; // again, just to be sure | |
| a = value; // third time's a charm | |
| if (a != value) // did it work? | |
| { | |
| a = value; | |
| } | |
| while (a != value) // ok, now brute force it | |
| { | |
| a = value; | |
| } | |
| } | |
| } | |
| catch // cosmic rays most probably | |
| { | |
| a = value; | |
| } | |
| finally | |
| { | |
| a = value; | |
| } | |
| } | |
| get | |
| { | |
| return a; | |
| } | |
| } |
Author
Author
" You can never be too careful. Those cosmic rays can really mess up your day otherwise. "
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
" It's this kind of this forward planning that means bug-free code! "
https://twitter.com/Gavoir/status/420874528810872832