You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently Is(Self)Busy is only a bool. This must not change with respect to the public api.
But handling that bool should be instead an integer to count busyness and non busyness.
Something like the following would today end the "busyness" early eventhogh it's not expected/desired:
publicvoidFoo(){try{
MarkAsBusy();// more locs
Bar();// more locs}finally{
MarkAsIdle();}}publicvoidBar(){// Do stuff here
MarkAsIdle();}
With such a structure the busyness would end early. With an internal counter we could more easily handle the busy flag.
Something like this:
privateint_isBusyCounter;
MarkAsBusy(){
Interlocked.Increment(ref _isBusyCounter);// Other stuff the implementation needs}
MarkAsIdle(){
Interlocked.Decrement(ref _isBusyCounter);// Other stuff the implementation needs}
With this as long as the dev ensure he's calling MarkBusy() and MarkIdle() in pairs the busy state will always be correct without worrying about where the method is used.
The text was updated successfully, but these errors were encountered:
Currently
Is(Self)Busy
is only abool
. This must not change with respect to the public api.But handling that bool should be instead an integer to count busyness and non busyness.
Something like the following would today end the "busyness" early eventhogh it's not expected/desired:
With such a structure the busyness would end early. With an internal counter we could more easily handle the busy flag.
Something like this:
With this as long as the dev ensure he's calling MarkBusy() and MarkIdle() in pairs the busy state will always be correct without worrying about where the method is used.
The text was updated successfully, but these errors were encountered: