Made code in OperationQueue more readable; added new class PartialStream which wraps a segment of a larger stream as if it was a separate stream, allowing access to certain regions of a stream to be prohibited and headers of a stream to be cut off without requiring a lengthy copy operation

git-svn-id: file:///srv/devel/repo-conversion/nusu@134 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2009-05-05 19:31:05 +00:00
parent 1c317b3f66
commit 7e9e0e2bf1
6 changed files with 800 additions and 12 deletions

View file

@ -119,10 +119,10 @@ namespace Nuclex.Support.Scheduling {
copy(this, eventArguments);
}
/// <summary>Prepares the current operation and calls its Begin() method</summary>
/// <summary>Prepares the current operation and calls its Start() method</summary>
/// <remarks>
/// This subscribes the queue to the events of to the current operation
/// and launches the operation by calling its Begin() method.
/// and launches the operation by calling its Start() method.
/// </remarks>
private void startCurrentOperation() {
OperationType operation = this.children[this.currentOperationIndex].Transaction;
@ -168,8 +168,8 @@ namespace Nuclex.Support.Scheduling {
/// <summary>Called when the current executing operation ends</summary>
/// <param name="sender">Operation that ended</param>
/// <param name="e">Not used</param>
private void asyncOperationEnded(object sender, EventArgs e) {
/// <param name="arguments">Not used</param>
private void asyncOperationEnded(object sender, EventArgs arguments) {
// Unsubscribe from the current operation's events and update the
// accumulating progress counter
@ -196,16 +196,17 @@ namespace Nuclex.Support.Scheduling {
/// <summary>Called when currently executing operation makes progress</summary>
/// <param name="sender">Operation that has achieved progress</param>
/// <param name="e">Not used</param>
private void asyncOperationProgressChanged(object sender, ProgressReportEventArgs e) {
/// <param name="arguments">Not used</param>
private void asyncOperationProgressChanged(
object sender, ProgressReportEventArgs arguments
) {
// Determine the completed weight of the currently executing operation
float currentOperationCompletedWeight =
e.Progress * this.children[this.currentOperationIndex].Weight;
float operationWeight = this.children[this.currentOperationIndex].Weight;
float operationCompletedWeight = arguments.Progress * operationWeight;
// Build the total normalized amount of progress for the queue
float progress =
(this.completedWeight + currentOperationCompletedWeight) / this.totalWeight;
float progress = (this.completedWeight + operationCompletedWeight) / this.totalWeight;
// Done, we can send the actual progress to any event subscribers
OnAsyncProgressChanged(progress);