public static KernelLinkDelegate CreateKernelLinkDelegate() { IKernelLink ml = HMathLinkFactory.CreateKernelLink(); ml.WaitAndDiscardAnswer(); return(new KernelLinkDelegate { ml = ml, }); }
public static T Evaluate <T>(string evaluate, Func <IKernelLink, T> GetT) { IKernelLink ml = HMathLinkFactory.CreateKernelLink(); ml.WaitAndDiscardAnswer(); ml.Evaluate(evaluate); ml.WaitForAnswer(); T result; try { result = GetT(ml); //result = ml.GetDoubleArray(); //result = ml.GetObject(); } catch { result = default(T); //result = null; } ml.Close(); return(result); }