Class InterruptMonitor
InterruptMonitor class
Represents all operator about the interrupt.
public class InterruptMonitor : AbstractInterruptMonitor
Constructors
Properties
Methods
Name | Description |
---|
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