HotDog's Blog

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

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

OctNovember 2009Dec
SMTWTFS
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

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