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:
parent
0ada9998e2
commit
10d6533b50
|
@ -128,7 +128,9 @@ namespace Nuclex.Support.Tracking {
|
|||
|
||||
/// <summary>Waits until the background process finishes</summary>
|
||||
public virtual void Wait() {
|
||||
WaitHandle.WaitOne();
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user