.NET/Link API Version 1.7 USE FRAMES

IKernelLink.WasInterrupted Property

Tells whether the user has attempted to abort the computation.

[Visual Basic]
Property WasInterrupted As Boolean
[C#]
bool WasInterrupted {get; set;}

Remarks

This method is usable only in .NET code that is invoked in a call from Mathematica, as described in Part 1 of the .NET/Link User Guide. In other words, it is only used in code that is called from a Mathematica session via the "installable .NET" mechanism. Programmers who are launching the kernel and controlling it from a .NET program will have no use for this method.

The IKernelLink object on which this method will be called will probably be obtained via the StdLink.Link property.

When the user tries to interrupt a Mathematica computation that is in the middle of a call into .NET, the interrupt request is sent to .NET. If a .NET method makes no attempt to honor interrupt requests, then after the method call completes .NET/Link will execute the Mathematica function Abort[], causing the entire Mathematica computation to end and return the result $Aborted. If you want to detect interrupts within a .NET method, for example to break out of a long .NET computation, call WasInterrupted to determine if an interrupt request has been received. If it returns true, then you can simply return from your method, and .NET/Link will take care of calling Abort[] for you. If your method returns a value, the value will be ignored. For example, you could put code like the following into a time-intensive loop you were running:

IKernelLink ml = StdLink.Link;
if (ml.WasInterrupted)
    return;
If you want to do something other than call Abort[] in response to the interrupt you should call BeginManual, send back a result manually, and then set WasInterrupted = false. Setting it to false tells .NET/Link that you have handled the interrupt manually and therefore .NET/Link should not try to send back Abort[]:
IKernelLink ml = StdLink.Link;
if (ml.WasInterrupted) {
    ml.BeginManual();
    ml.Put("Interrupted at iteration " + i);
    ml.WasInterrupted = false;
    return;
}

See Also

IKernelLink Interface | Wolfram.NETLink Namespace