MathKernel Class

MathKernel is a non-visual component that provides a very high-level interface for interacting with the Wolfram Language. It is especially intended for use in visual programming environments, as it is highly configurable via properties.

Definition

Namespace: Wolfram.NETLink
Assembly: Wolfram.NETLink (in Wolfram.NETLink.dll) Version: 2.0.0.0
C#
public class MathKernel : Component
Inheritance
Object    MarshalByRefObject    Component    MathKernel

Remarks

MathKernel provides a higher-level interface than IKernelLink. For many types of .NET programs that use the Wolfram Language for computations, the IKernelLink interface provides ideal functionality. For some types of programs, however, programmers might find the MathKernel object even easier to use. This is especially true for programs that want to capture not just the result of a computation, but also messages, Print output, or graphics generated as side effects of the computation.

The typical use of a MathKernel is to set the Input property, call the Compute method, and when it returns you can get the various outputs produced by the computation via the Result, Messages, PrintOutput, and Graphics properties.

The .NET/Link distribution contains a sample program showing the use of MathKernel. You can find it in [Wolfram directory]\SystemFiles\Links\NETLink\Examples\Part2\MathKernelApp.

Constructors

MathKernel Constructs a new MathKernel object.
MathKernel(IKernelLink) Constructs a new MathKernel object that uses the specified link.

Properties

AutoCloseLink Gets or sets whether the link should be closed when this MathKernel object is disposed.
CanRaiseEventsGets a value indicating whether the component can raise an event.
(Inherited from Component)
CaptureGraphics Get or sets whether this MathKernel object should capture Wolfram Language graphics output generated during a computation.
CaptureMessages Get or sets whether this MathKernel object should capture Wolfram Language Message output generated during a computation.
CapturePrint Get or sets whether this MathKernel object should capture Wolfram Language Print output generated during a computation.
ContainerGets the IContainer that contains the Component.
(Inherited from Component)
DesignModeGets a value that indicates whether the Component is currently in design mode.
(Inherited from Component)
EventsGets the list of event handlers that are attached to this Component.
(Inherited from Component)
Graphics Gets the accumulated Images from the Wolfram Language graphics output during the last call to Compute.
GraphicsBytes Gets the accumulated graphics output during the last call to Compute. The data for each graphic is in the form of the raw image bytes in whatever format you reuested via the GraphicsFormat property.
GraphicsFormat Gets or sets the image format for Wolfram Language graphics generated during a computation.
GraphicsHeight Gets or sets the height, in pixels, for Wolfram Language graphics generated during a computation.
GraphicsResolution Gets or sets the resolution, in pixels per inch, for Wolfram Language graphics generated during a computation.
GraphicsWidth Gets or sets the width, in pixels, for Wolfram Language graphics generated during a computation.
HandleEvents Gets or sets whether the the thread on which Compute is called should continue to handle application events during the period that Compute is waiting for the result.
Input Gets or sets the input to the Wolfram session that will be used in the next call to Compute.
IsComputing Gets whether the Wolfram Language is currently busy with a computation (that is, whether Compute is currently running).
IsConnected Gets whether the link has been connected (typically, this means that the kernel has been launched and is ready for use).
Link Gets or sets the link that this MathKernel will use.
LinkArguments Gets or sets the command string that will be passed to CreateKernelLink to attach to the Wolfram Language kernel.
Messages Gets the accumulated strings from the Wolfram Language Message output during the last call to Compute.
PageWidth Gets or sets the width to which output should be wrapped.
PrintOutput Gets the accumulated strings from the Wolfram Language Print output during the last call to Compute.
Result Gets the result from the last call to Compute.
ResultFormat Gets or sets the format in which you want the result of evaluations to be returned.
SiteGets or sets the ISite of the Component.
(Inherited from Component)
UseFrontEnd Gets or sets whether the Wolfram notebook front end should be used in the background for graphics rendering services.

Methods

Abort Sends a request to abort the computation currently in progress.
Clear Clears all the "output" values from the previous computation.
Compute Sends the current value of the Input property to the Wolfram Language for evaluation.
Compute(String) Sends the given string to the Wolfram Language for evaluation.
Connect Creates and connects the link, if it has not already been connected.
CreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject)
Dispose Closes the link used by this MathKernel, if the AutoCloseLink property is true.
Dispose(Boolean)Releases the unmanaged resources used by the Component and optionally releases the managed resources.
(Inherited from Component)
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Finalize Closes the link if the AutoCloseLink property is set to true.
(Overrides ComponentFinalize)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject)
GetServiceReturns an object that represents a service provided by the Component or by its Container.
(Inherited from Component)
GetTypeGets the Type of the current instance.
(Inherited from Object)
InitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
MemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject)
ToStringReturns a String containing the name of the Component, if any. This method should not be overridden.
(Inherited from Component)

Events

DisposedOccurs when the component is disposed by a call to the Dispose method.
(Inherited from Component)

See Also