.NET/Link API Version 1.6 USE FRAMES

IKernelLink.WaitForAnswer Method 

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

[Visual Basic]
Function WaitForAnswer() As PacketType
[C#]
PacketType WaitForAnswer();

Return Value

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 or a manual sequence of Put methods.

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

Exception Type Condition
MathLinkException On any MathLink error.

See Also

IKernelLink Interface | Wolfram.NETLink Namespace | WaitAndDiscardAnswer