Added an obvious, simple and important optimization: when Transaction.Wait() is called, the transaction will not create a WaitHandle if it has already ended

git-svn-id: file:///srv/devel/repo-conversion/nusu@142 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2009-05-28 19:55:48 +00:00
parent 0ada9998e2
commit 10d6533b50

View File

@ -128,8 +128,10 @@ namespace Nuclex.Support.Tracking {
/// <summary>Waits until the background process finishes</summary>
public virtual void Wait() {
if(!this.ended) {
WaitHandle.WaitOne();
}
}
#if !COMPACTFRAMEWORK
@ -141,6 +143,10 @@ namespace Nuclex.Support.Tracking {
/// True if the background process completed, false if the timeout was reached
/// </returns>
public virtual bool Wait(TimeSpan timeout) {
if(this.ended) {
return true;
}
return WaitHandle.WaitOne(timeout, false);
}
@ -154,6 +160,10 @@ namespace Nuclex.Support.Tracking {
/// True if the background process completed, false if the timeout was reached
/// </returns>
public virtual bool Wait(int timeoutMilliseconds) {
if(this.ended) {
return true;
}
return WaitHandle.WaitOne(timeoutMilliseconds, false);
}