Class InterruptMonitor

InterruptMonitor class

Represents all operator about the interrupt.

public class InterruptMonitor : AbstractInterruptMonitor

Constructors

NameDescription
InterruptMonitor()The default constructor.

Properties

NameDescription
override IsInterruptionRequested { get; }Mark the monitor as requesting interruption
virtual TerminateWithoutException { get; }When procedure is interrupted, whether terminate the procedure quietly or throw an Exception. Default is false, that is, when IsInterruptionRequested is true, a CellsException with code Interrupted will be thrown.(Inherited from AbstractInterruptMonitor.)

Methods

NameDescription
Interrupt()Interrupt the current operator.

Examples

// Called: InterruptMonitor monitor = new InterruptMonitor();
[Test]
        public void Type_InterruptMonitor()
        {
            string filePath = Constants.PivotTableSourcePath + @"JAVA42341_";

            DateTime start = DateTime.Now;
            Workbook workbook = new Workbook(filePath + "Mkw-50.xlsx");

            InterruptMonitor monitor = new InterruptMonitor();
            workbook.InterruptMonitor = monitor;
            try
            {
                Console.WriteLine("Now convert");
                monitor.Interrupt();
                workbook.Save(CreateFolder(filePath) + "out.pdf", SaveFormat.Pdf);
                Console.WriteLine("Converted in " + DateTime.Now.Subtract(start).Milliseconds + "ms");
            }
            catch (CellsException e)
            {
                if (e.Code == ExceptionType.Interrupted)
                {
                    Console.WriteLine("The save thread interrupted in " + DateTime.Now.Subtract(start).Milliseconds + "ms");
                }
                else
                {
                    throw e;
                }
            }
        }

See Also