SystemTimeInterruptMonitor class

SystemTimeInterruptMonitor class

Simple implementation of AbstractInterruptMonitor by checking and comparing current system time with user specified limit.

Inheritance: SystemTimeInterruptMonitorAbstractInterruptMonitor

The SystemTimeInterruptMonitor type exposes the following members:

Constructors

ConstructorDescription
initConstructs one interruption monitor.

Properties

PropertyDescription
is_interruption_requestedThis implementation just checks whether the time cost(from the time when starting this monitor to now) is greater than user specified limit.
terminate_without_exceptionSee AbstractInterruptMonitor.terminate_without_exception.
This property is specified by user when constructing this monitor instance.

Methods

MethodDescription
start_monitorStarts 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.

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.

Example

The following example shows how to monitor the load and save procedure with specified time limit:

from aspose.cells import LoadOptions, SystemTimeInterruptMonitor, Workbook

monitor = SystemTimeInterruptMonitor(False)
lopts = LoadOptions()
lopts.interrupt_monitor = monitor
monitor.start_monitor(1000)
wb = 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.start_monitor(1500)
wb.save("result.xlsx")

See Also