Skip to content

Instantly share code, notes, and snippets.

@EdGuiness
Last active January 2, 2016 14:09
Show Gist options
  • Select an option

  • Save EdGuiness/8315115 to your computer and use it in GitHub Desktop.

Select an option

Save EdGuiness/8315115 to your computer and use it in GitHub Desktop.
Use this code when you want to be sure it happens
/// <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;
}
}
@EdGuiness
Copy link
Author

" It's this kind of this forward planning that means bug-free code! "

https://twitter.com/Gavoir/status/420874528810872832

@EdGuiness
Copy link
Author

" You can never be too careful. Those cosmic rays can really mess up your day otherwise. "

https://twitter.com/sdarlington/status/420872054100221952

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment