Trimmed down the Request class and provided it with a clear way to pass results to the user of the request
git-svn-id: file:///srv/devel/repo-conversion/nusu@63 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
c21ba759cc
commit
1161ef8f25
4 changed files with 114 additions and 36 deletions
|
@ -109,7 +109,7 @@ namespace Nuclex.Support.Scheduling {
|
|||
/// <summary>Moves the operation into the ended state with an exception</summary>
|
||||
/// <param name="exception">Exception</param>
|
||||
public void SetEnded(Exception exception) {
|
||||
SetException(exception);
|
||||
this.exception = exception;
|
||||
OnAsyncEnded();
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,18 @@ namespace Nuclex.Support.Scheduling {
|
|||
OnAsyncProgressUpdated(progress);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the specific request implementation to re-throw an exception if
|
||||
/// the background process finished unsuccessfully
|
||||
/// </summary>
|
||||
protected override void ReraiseExceptions() {
|
||||
if(this.exception != null)
|
||||
throw this.exception;
|
||||
}
|
||||
|
||||
/// <summary>Exception that has occured in the background process</summary>
|
||||
private volatile Exception exception;
|
||||
|
||||
}
|
||||
|
||||
#endregion // class TestOperation
|
||||
|
|
|
@ -84,6 +84,15 @@ namespace Nuclex.Support.Scheduling {
|
|||
startCurrentOperation();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the specific request implementation to re-throw an exception if
|
||||
/// the background process finished unsuccessfully
|
||||
/// </summary>
|
||||
protected override void ReraiseExceptions() {
|
||||
if(this.exception != null)
|
||||
throw this.exception;
|
||||
}
|
||||
|
||||
/// <summary>Prepares the current operation and calls its Begin() method</summary>
|
||||
/// <remarks>
|
||||
/// This subscribes the queue to the events of to the current operation
|
||||
|
@ -121,7 +130,7 @@ namespace Nuclex.Support.Scheduling {
|
|||
OnAsyncProgressUpdated(this.completedWeight / this.totalWeight);
|
||||
}
|
||||
catch(Exception exception) {
|
||||
SetException(exception);
|
||||
this.exception = exception;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,7 +144,7 @@ namespace Nuclex.Support.Scheduling {
|
|||
endCurrentOperation();
|
||||
|
||||
// Only jump to the next operation if no exception occured
|
||||
if(OccuredException == null) {
|
||||
if(this.exception == null) {
|
||||
|
||||
++this.currentOperationIndex;
|
||||
|
||||
|
@ -183,6 +192,8 @@ namespace Nuclex.Support.Scheduling {
|
|||
private float completedWeight;
|
||||
/// <summary>Index of the operation currently executing</summary>
|
||||
private int currentOperationIndex;
|
||||
/// <summary>Exception that has occured in the background process</summary>
|
||||
private volatile Exception exception;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -70,15 +70,26 @@ namespace Nuclex.Support.Scheduling {
|
|||
Execute();
|
||||
}
|
||||
catch(Exception exception) {
|
||||
SetException(exception);
|
||||
this.exception = exception;
|
||||
}
|
||||
finally {
|
||||
OnAsyncEnded();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the specific request implementation to re-throw an exception if
|
||||
/// the background process finished unsuccessfully
|
||||
/// </summary>
|
||||
protected override void ReraiseExceptions() {
|
||||
if(this.exception != null)
|
||||
throw this.exception;
|
||||
}
|
||||
|
||||
/// <summary>Whether to use the ThreadPool for obtaining a background thread</summary>
|
||||
private bool useThreadPool;
|
||||
/// <summary>Exception that has occured in the background process</summary>
|
||||
private volatile Exception exception;
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue