HotDog's Blog

Hotdog (Robert Verpalen) about C# and vb.net

vbCity Blogs moved to:
http://cs.vbcity.com/blogs
  Home :: Syndication  :: Login

JanFebruary 2010Mar
SMTWTFS
31123456
78910111213
14151617181920
21222324252627
28123456
78910111213

Articles

Archives

Topics

CONTACT

Fun but useful linkies

General

VS 2005

Wolfenstein ET

This is not on what should be suspended, but more on the property that regulates it. Usually on setting the suspend to false, stuff starts happening, but what if the suspend is set to false from within code that's also using the suspend settings?

Elementary my dear Watson: use a counter to keep the property and a bool as the interface. For example: a suspend of a setheight function:

int suspendsetheightcount;
bool
SuspendSetHeight
{
get{return suspendsetheightcount>0;}
set

{
if(value)
suspendsetheightcount++;
else if(--suspendsetheightcount==0)
{
//do stuff that's supposed to happen when
//the suspend is over here.
}
}
}
I'll be the first to admit this isn't exactly brainsurgery, but just wanted to share it anyway, because using such a structure right from the beginning can prevent worrying about it in the first place ;-)
posted on Saturday, May 21, 2005 7:29 AM