Some more unit tests; improved documentation; improve useless speed optimization of an exceptional case

git-svn-id: file:///srv/devel/repo-conversion/nusu@39 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2007-07-12 22:16:11 +00:00
parent 81cb56f468
commit acbb07d6b5
3 changed files with 33 additions and 24 deletions

View file

@ -39,24 +39,13 @@ namespace Nuclex.Support.Scheduling {
/// </remarks>
public virtual void End() {
// Use some ingenious double-checked locking to set the endCalled flag.
// Quite a lot of effort for a mere safety feature that prevents the programmer
// from calling End() twice.
bool error;
if(!this.endCalled) {
lock(this) {
if(!this.endCalled) {
this.endCalled = true;
error = false;
} else {
error = true;
}
} // lock
} else {
error = true;
// By design, end can only be called once!
lock(this) {
if(this.endCalled)
throw new InvalidOperationException("End() has already been called");
this.endCalled = true;
}
if(error)
throw new InvalidOperationException("End() has already been called");
// If the progression itself hasn't ended yet, block the caller until it has.
if(!Ended)