Class SlowLoadableComponent<T>
A LoadableComponent<T> which might not have finished loading when Load() returns.
After a call to Load(), the IsLoaded property should continue to return false until the component has fully loaded.
// Example usage:
new MySlowComponent().Load();
public abstract class SlowLoadableComponent<T> : LoadableComponent<T>, ILoadableComponent where T : SlowLoadableComponent<T>
Type Parameters
T
The type to be returned (normally the subclass' type)
- Inheritance
-
SlowLoadableComponent<T>
- Implements
- Inherited Members
Remarks
Override the HandleErrors() method to check for error conditions which caused Load() to fail.
Constructors
SlowLoadableComponent(TimeSpan)
Initializes a new instance of the SlowLoadableComponent<T> class.
protected SlowLoadableComponent(TimeSpan timeout)
Parameters
SlowLoadableComponent(TimeSpan, IClock)
Initializes a new instance of the SlowLoadableComponent<T> class.
protected SlowLoadableComponent(TimeSpan timeout, IClock clock)
Parameters
timeout
TimeSpanThe TimeSpan within which the component should be loaded.
clock
IClockThe IClock to use when measuring the timeout.
Exceptions
- ArgumentNullException
If
clock
is null.
Properties
Clock
Gets the clock object providing timing for monitoring the load status of this component.
protected IClock Clock { get; }
Property Value
SleepInterval
Gets or sets the time to sleep between each check of the load status of the component.
public TimeSpan SleepInterval { get; set; }
Property Value
Timeout
Gets the timeout interval before which this component must be considered loaded.
protected TimeSpan Timeout { get; }
Property Value
Methods
HandleErrors()
Checks for well known error cases, which would mean that loading has finished, but an error condition was seen.
protected virtual void HandleErrors()
Remarks
This method should be overridden so that expected errors can be automatically handled.
Load()
Ensures that the component is currently loaded.
public override T Load()
Returns
- T
The loaded component.
Remarks
This is equivalent to the Get() method in Java version.
Wait()
Waits between polls of the load status of this component.
protected virtual void Wait()