ThreadedCalculation Class |
Namespace: AGI.Foundation.Infrastructure.Threading
The ThreadedCalculation type exposes the following members.
Name | Description | |
---|---|---|
ThreadedCalculation | Initializes a new instance. |
Name | Description | |
---|---|---|
ContinueExecution |
Gets or sets a value indicating whether a thread should continue its threaded execution.
It is the responsibility of derived classes to check this value in their ExecuteWorker(Int32)
method and to stop their execution if it is false.
| |
MultithreadSubCalculations |
Gets or sets a value indicating whether subcalculations should use the current ThreadingPolicy.
By default, this is false, indicating that the subcalculations will see a
ThreadingPolicy specifying that further operations be executed in the thread that invoked those operations.
New threads created for use by the threaded calculation will use the default threading policy that was previously configured by
calling UseCurrentAsDefault.
| |
NumberOfThreads |
Gets the number of threads to be used to perform the calculation.
|
Name | Description | |
---|---|---|
Dispose |
Releases any resources associated with this instance.
| |
Dispose(Boolean) |
Releases any resources associated with this instance.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
ExecuteInOneThread |
Starts the calculation using the calling thread as the one and only worker thread.
This method does not return until the calculation is completed.
| |
ExecuteWorker |
Implement this method to perform the calculation. It is called NumberOfThreads times,
each call in a separate thread.
| |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
Finish |
This method is called after all worker threads have finished executing.
It Does nothing if not overridden by the derived class.
| |
ForTParameter(Int32, Int32, TParameter, ITrackCalculationProgress, ThreadedCalculationBodyCallbackTParameter) |
A 'for' loop that is parallelized among multiple threads according to the
ThreadingPolicy active in the calling thread.
The loop behaves as if written as for (int i = start; i < stop; ++i).
Inside the body callback, the ThreadingPolicy will
be configured to use only the calling thread for any further parallelizable operations.
This usually improves performance by putting the parallelism where it is most useful:
in the 'for' loop itself. However, if you do wish to parallelize operations invoked
inside the 'for' loop, you must explicitly set the ThreadingPolicy
inside the callback.
| |
ForTParameter(Int32, Int32, TParameter, ITrackCalculationProgress, ThreadedCalculationBodyCallbackWithProgressTParameter) | A 'for' loop that is parallelized among multiple threads according to the ThreadingPolicy active in the calling thread. The loop behaves as if written as for (int i = start; i < stop; ++i). Inside the body callback, the ThreadingPolicy will be configured to use only the calling thread for any further parallelizable operations. This usually improves performance by putting the parallelism where it is most useful: in the 'for' loop itself. However, if you do wish to parallelize operations invoked inside the 'for' loop, you must explicitly set the ThreadingPolicy inside the callback. The body of the 'for' loop is given an ITrackCalculationProgress instance that can be used to report detailed information about the progress of individual loop iterations. It is not recommended to use this overload when looping through a large number of iterations or when detailed information about the progress of individual iterations is not required, because there is some overhead to the detailed progress reporting. | |
ForTParameter1, TParameter2(Int32, Int32, TParameter1, TParameter2, ITrackCalculationProgress, ThreadedCalculationBodyCallback2TParameter1, TParameter2) |
A 'for' loop that is parallelized among multiple threads according to the
ThreadingPolicy active in the calling thread.
The loop behaves as if written as for (int i = start; i < stop; ++i).
Inside the body callback, the ThreadingPolicy will
be configured to use only the calling thread for any further parallelizable operations.
This usually improves performance by putting the parallelism where it is most useful:
in the 'for' loop itself. However, if you do wish to parallelize operations invoked
inside the 'for' loop, you must explicitly set the ThreadingPolicy
inside the callback.
| |
ForTParameter1, TParameter2(Int32, Int32, TParameter1, TParameter2, ITrackCalculationProgress, ThreadedCalculationBodyCallbackWithProgress2TParameter1, TParameter2) | A 'for' loop that is parallelized among multiple threads according to the ThreadingPolicy active in the calling thread. The loop behaves as if written as for (int i = start; i < stop; ++i). Inside the body callback, the ThreadingPolicy will be configured to use only the calling thread for any further parallelizable operations. This usually improves performance by putting the parallelism where it is most useful: in the 'for' loop itself. However, if you do wish to parallelize operations invoked inside the 'for' loop, you must explicitly set the ThreadingPolicy inside the callback. The body of the 'for' loop is given an ITrackCalculationProgress instance that can be used to report detailed information about the progress of individual loop iterations. It is not recommended to use this overload when looping through a large number of iterations or when detailed information about the progress of individual iterations is not required, because there is some overhead to the detailed progress reporting. | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Start |
Starts the threaded calculation. This method returns immediately after creating the appropriate
number of threads. It does not wait for the calculation to be completed.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
WaitUntilDone |
Blocks the calling thread until the calculation has completed.
If an exception occurs (or has already occurred) in any of the calculation threads, this
method will throw a ThreadException wrapping the exception that was thrown
by the calculation thread. The actual exception that occurred can be found in the
InnerException property.
|