HotDog's Blog

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

This blog hosted by:
http://blogs.vbcity.com      
  Home :: Syndication  :: Login

AprMay 2005Jun
SMTWTFS
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

Articles

Archives

Topics

CONTACT

Fun but useful linkies

General

VS 2005

Wolfenstein ET

Saturday, May 21, 2005 #

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 @ 7:29 AM