Reads and discards all packets that arrive up until the packet that contains the result of the computation.
The packet type that held the answer, typically PacketType.Return.
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();
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.
Exception Type | Condition |
---|---|
MathLinkException | On any MathLink error. |
IKernelLink Interface | Wolfram.NETLink Namespace | WaitAndDiscardAnswer