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

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class CellsClassInterruptMonitorDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            
            // Add some sample data
            Worksheet worksheet = workbook.Worksheets[0];
            worksheet.Cells["A1"].PutValue("Sample Data");
            
            // Create and assign interrupt monitor
            InterruptMonitor monitor = new InterruptMonitor();
            workbook.InterruptMonitor = monitor;
            
            try
            {
                Console.WriteLine("Starting save operation...");
                
                // Simulate interrupting the operation
                monitor.Interrupt();
                
                // Attempt to save (should be interrupted)
                workbook.Save("output.pdf", SaveFormat.Pdf);
                Console.WriteLine("Save completed successfully.");
            }
            catch (CellsException e)
            {
                if (e.Code == ExceptionType.Interrupted)
                {
                    Console.WriteLine("Operation was successfully interrupted.");
                }
                else
                {
                    Console.WriteLine("Error occurred: " + e.Message);
                }
            }
        }
    }
}

See Also