IKernelLinkWaitForAnswer Method

Reads and discards all packets that arrive up until the packet that contains the result of the computation.

Definition

Namespace: Wolfram.NETLink
Assembly: Wolfram.NETLink (in Wolfram.NETLink.dll) Version: 2.0.0.0
C#
PacketType WaitForAnswer()

Return Value

PacketType
The packet type that held the answer, typically PacketType.Return.

Remarks

After this method returns, it is your responsibility to read the contents of the packet that holds the result. If you are not interested in examining the result of the evaluation, use WaitAndDiscardAnswer instead.

Use this method after sending an expression to evaluate with Evaluate(String) or a manual sequence of Put methods.

Example

C#
ml.Evaluate("2+2");
ml.WaitForAnwser();
int result = ml.GetInteger();
// It is not strictly necessary to call newPacket, since we have read the entire packet contents, but it is good style.
ml.NewPacket();
Examples of packets that arrive before the result and are discarded are PacketType.Text, PacketType.Message, PacketType.Display, etc. If you want to examine or operate on the incoming packets that are discarded by this method, use the PacketArrived event.

It returns the packet type that held the result of the computation. Typically, this will be PacketType.Return. However, in the unlikely event that you are manually sending evaluations inside an EnterTextPacket or EnterExpressionPacket, the packet will be different, and there are some further issues that you need to understand; consult the .NET/Link User Guide for details.

Exceptions

MathLinkExceptionOn any MathLink error.

See Also