Class SystemTimeInterruptMonitor
Namespace: Aspose.Cells
Assembly: Aspose.Cells.dll (25.2.0)
Simple implementation of Aspose.Cells.AbstractInterruptMonitor by checking and comparing current system time with user specified limit.
public class SystemTimeInterruptMonitor : AbstractInterruptMonitor
Inheritance
object ← AbstractInterruptMonitor ← SystemTimeInterruptMonitor
Inherited Members
AbstractInterruptMonitor.IsInterruptionRequested, AbstractInterruptMonitor.TerminateWithoutException, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
The following example shows how to monitor the load and save procedure with specified time limit:
csharp
[C#]
SystemTimeInterruptMonitor monitor = new SystemTimeInterruptMonitor(false);
LoadOptions lopts = new LoadOptions();
lopts.InterruptMonitor = monitor;
monitor.StartMonitor(1000); //time limit is 1 second
Workbook wb = new Workbook("Large.xlsx", lopts);
//if the time cost of loading the template file exceeds one second, interruption will be required and exception will be thrown here
//otherwise starts to monitor the save procedure
monitor.StartMonitor(1500); //time limit is 1.5 seconds
wb.Save("result.xlsx");
Remarks
This implementation is just a simple solution for simple scenarios. It needs to frequently retrieve and check the system time so itself may have a negative impact on performance to some extent.
Constructors
SystemTimeInterruptMonitor(bool)
Constructs one interruption monitor.
public SystemTimeInterruptMonitor(bool terminateWithoutException)
Parameters
terminateWithoutException
bool
Aspose.Cells.AbstractInterruptMonitor.TerminateWithoutException
Properties
IsInterruptionRequested
This implementation just checks whether the time cost(from the time when starting this monitor to now) is greater than user specified limit.
public override bool IsInterruptionRequested { get; }
Property Value
TerminateWithoutException
See Aspose.Cells.AbstractInterruptMonitor.TerminateWithoutException. This property is specified by user when constructing this monitor instance.
public override bool TerminateWithoutException { get; }
Property Value
Methods
StartMonitor(int)
Starts the monitor with the specified time limit. The start time to calculate time cost is just when this method is called, so the procedure which needs to be monitored should be started just after this call.
public void StartMonitor(int msLimit)
Parameters
msLimit
int
time limit(ms) to require the interruption.