C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
SimulationStatus.cs
Go to the documentation of this file.
1using System;
2
4{
6 [Obsolete("Deprecated with the SimulationStatusMonitor.")]
7 public class SimulationStatus
8 {
9 #region Constants / Types
11 public enum SimulationState
12 {
14 Unknown,
16 Queued,
18 Running,
22 Error
23 }
24 #endregion Constants / Types
25
26 #region Private Fields
27 private Exception _exception;
28 private SimulationState _state = SimulationState.Queued;
29 private double _timeRemaining;
30 #endregion Private Fields
31
32 #region Public Properties
34 public bool BeingPolled { get; set; }
35
37 public double TimeRemaining
38 {
39 get { return _timeRemaining; }
40 set
41 {
42 if (!(Math.Abs(value - _timeRemaining) > Double.Epsilon)) return;
43 _timeRemaining = value;
44 InvokeSimulationStatusChanged();
45 }
46 }
47
50 {
51 get { return _state; }
52 set
53 {
54 if (value == _state) return;
55 _state = value;
56 InvokeSimulationStatusChanged();
57 }
58 }
59
62 {
63 get { return _exception; }
64 set
65 {
66 if (value != null)
67 State = SimulationState.Error;
68 _exception = value;
69 }
70 }
71
73 public DateTime LastUpdate { get; private set; }
74
76 public string Id { get; private set; }
77
79 public string Description { get; set; }
80 #endregion Public Properties
81
82 #region Public Events
86 public delegate void SimulationStatusChangedHandler(object sender, EventArgs e);
87
90
91 private void InvokeSimulationStatusChanged()
92 {
93 LastUpdate = DateTime.UtcNow;
94 SimulationStatusChanged?.Invoke(this, EventArgs.Empty);
95 }
96 #endregion Public Events
97
98 #region Constructor
102 public SimulationStatus(string id, string description = null)
103 {
104 Id = id;
105 Description = description;
106 }
107 #endregion Constructor
108 }
109}
Describes the status of a simulation being monitored.
SimulationStatus(string id, string description=null)
Creates a new SimulationStatus object.
delegate void SimulationStatusChangedHandler(object sender, EventArgs e)
A handler that can respond to a SimulationStatusChanged event.
bool BeingPolled
Determines whether the associated simulation is actively being polled.
string Description
The description of the resource being simulated.
string Id
The id of the resource being simulated.
Exception Exception
The exception associated with this simulation, if it is in an error state.
SimulationState
The running state of a simulation represented by a SimulationStatus object.
@ Queued
Simulation request has been submitted, but simulation has not been run.
@ Unknown
SimulationStatus is not properly initialized.
@ Error
Simulation is done running and has failed. Results will not be ready.
@ Complete
Simulation is done running and results should be ready.
DateTime LastUpdate
The time the server last responded to a poll request.
SimulationStatusChangedHandler SimulationStatusChanged
An event that fires whenever this SimulationStatus is updated.
SimulationState State
The running state of the simulation represented by this SimulationStatus object.
double TimeRemaining
Returns the estimated time remaining as of the last polled update from the server.