Skip to content

Instantly share code, notes, and snippets.

@jakesays-old
Created February 4, 2014 18:10
Show Gist options
  • Save jakesays-old/8809128 to your computer and use it in GitHub Desktop.
Save jakesays-old/8809128 to your computer and use it in GitHub Desktop.
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