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,8 +128,10 @@ namespace Nuclex.Support.Tracking {
|
||||||
|
|
||||||
/// <summary>Waits until the background process finishes</summary>
|
/// <summary>Waits until the background process finishes</summary>
|
||||||
public virtual void Wait() {
|
public virtual void Wait() {
|
||||||
|
if(!this.ended) {
|
||||||
WaitHandle.WaitOne();
|
WaitHandle.WaitOne();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if !COMPACTFRAMEWORK
|
#if !COMPACTFRAMEWORK
|
||||||
|
|
||||||
|
@ -141,6 +143,10 @@ namespace Nuclex.Support.Tracking {
|
||||||
/// True if the background process completed, false if the timeout was reached
|
/// True if the background process completed, false if the timeout was reached
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public virtual bool Wait(TimeSpan timeout) {
|
public virtual bool Wait(TimeSpan timeout) {
|
||||||
|
if(this.ended) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return WaitHandle.WaitOne(timeout, false);
|
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
|
/// True if the background process completed, false if the timeout was reached
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public virtual bool Wait(int timeoutMilliseconds) {
|
public virtual bool Wait(int timeoutMilliseconds) {
|
||||||
|
if(this.ended) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return WaitHandle.WaitOne(timeoutMilliseconds, false);
|
return WaitHandle.WaitOne(timeoutMilliseconds, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user