How to interrupt a running evaluation in MathLink
- To: mathgroup at smc.vnet.net
- Subject: [mg16896] How to interrupt a running evaluation in MathLink
- From: rmille1 at aol.com (RMille1)
- Date: Mon, 5 Apr 1999 02:24:29 -0400
- Organization: AOL http://www.aol.com
- Sender: owner-wri-mathgroup at wolfram.com
I'm using Mathlink in my C program to start a Mathlink kernel and send this expression to be evaluated: N[ReplaceAll["Some expression",x->"some variable"]] Everything is working otay. However, occasionally an expression I send causes the kernel to evaluate for longer than I would like it to. So what I want to do is interrupt the evaluation and abort just as it would from a command line with Ctr-C and abort, but through MathLink. Here's the snippet of code that will call it: pkt = MLFlush(Link); interval = 0; while((!MLReady(Link))&&(interval<=10)) { interval++; Sleep(500); } if(interval > 10) { dump = fopen("dump.txt","a");//test fprintf(dump,"\n/////////////////////Restarting Kernel///////////////////\n\n");//test fclose(dump); //test ***** Interrupt and Abort here. ************ return 0; } I know there's a way to do this with MLAbort from the kernel, but not the other way. Also I didn't use Loopback or mprep, One other thing. I found the MathLink Tutorial by Todd Gayley to be the best resource for learning how to use MathLink to start and run a Math kernel from C. However, it seems a little dated. I'm using char *argv[5] = {"-linkname", "c:\\progra~1\\wolfra~1\\mathem~1\\3.0\\math -mathlink", "-linkmode", "launch", NULL}; with MLOpen(), and that doesn't jive with the documentation in Mathematica 3.0 Is there a more up to date version available?