Created
February 4, 2014 18:10
-
-
Save jakesays-old/8809128 to your computer and use it in GitHub Desktop.
This file contains 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
struct Bar | |
{ | |
public ushort One; | |
public ushort Two; | |
} | |
class Foo | |
{ | |
private Bar _thing; | |
public Bar Thing | |
{ | |
get { return _thing; } | |
private set | |
{ | |
if (_thing.One == 0 && _thing.Two == 0) | |
{ | |
//locking this is usually bad juju, but it should only happen once | |
lock(this) | |
{ | |
if (_thing.One != 0 || _thing.Two != 0) | |
{ | |
return; | |
} | |
_thing = value; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment