Hi all, I am trying to make calls to R from an MFC application running on XP and am having problems blocking the application while the call executes. I have tried the following approaches to using R from the application (note that I set a wait cursor while R is executing). 1) call rcmd in BATCH mode using system(). This works well, except that I get the cmd window popping up... which makes the app look pretty tacky. 2) use the com interface. This works OK... sometimes. When I call R_Proxy_evaluate_noreturn by pressing OK in the dialog that starts the execution, if the cursor happens to be over the applications window when the dialog disappears, then I get my wait cursor and the application blocks. If the cursor is not over the applications window, then I don't get the wait cursor and the application seems to block after the first mouse click within the applications window. 3) use Rproxy.dll directly. The application does not block and I don't get a wait cursor at all. 4) integrate the code used by Rproxy into my application (in verbatim). The application does not block and I don't get a wait cursor at all. The things I have read about DLLs make statements like "a dll is just code and data loaded into your applications process", which I have taken to imply that the application should block while R is executing. This also seems to be implied by the discussion around the rtest example r-ext.pdf. Can someone offer any advice on whether there is some way to make my application block when configuring R? If not, is there a simple way to make the app block (I have never coded using threads before, am a relative newbie to MFC and am struggling to figure out how I would to block otherwise). Help would be greatly appreciated, Simon Knapp
You are not calling R, but rproxy.dll, part of a (D)COM interface. Try calling R itself (via R.dll). On Fri, 9 Dec 2005, Simon Knapp wrote:> Hi all, > > I am trying to make calls to R from an MFC application running on XP > and am having problems blocking the application while the call > executes. > > I have tried the following approaches to using R from the application > (note that I set a wait cursor while R is executing). > > 1) call rcmd in BATCH mode using system(). This works well, except > that I get the cmd window popping up... which makes the app look > pretty tacky. > > 2) use the com interface. This works OK... sometimes. When I call > R_Proxy_evaluate_noreturn by pressing OK in the dialog that starts the > execution, if the cursor happens to be over the applications window > when the dialog disappears, then I get my wait cursor and the > application blocks. If the cursor is not over the applications window, > then I don't get the wait cursor and the application seems to block > after the first mouse click within the applications window. > > 3) use Rproxy.dll directly. The application does not block and I don't > get a wait cursor at all. > > 4) integrate the code used by Rproxy into my application (in > verbatim). The application does not block and I don't get a wait > cursor at all. > > The things I have read about DLLs make statements like "a dll is just > code and data loaded into your applications process", which I have > taken to imply that the application should block while R is executing. > This also seems to be implied by the discussion around the rtest > example r-ext.pdf. > > Can someone offer any advice on whether there is some way to make my > application block when configuring R? If not, is there a simple way to > make the app block (I have never coded using threads before, am a > relative newbie to MFC and am struggling to figure out how I would to > block otherwise). > > Help would be greatly appreciated, > Simon Knapp > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Thanks for that rapid reply! In the fourth approach, I have compiled the functions R_proxy_init(), R_proxy_evaluate_noreturn(), R_proxy_term() and the callback functions defined in Baiers code directly into my application (I got them from the R source distribution and commented out the other functions). Rproxy.dll is not on my path. When I look through the R_proxy_init() it does the same things that are done in the rtest example (as far as I can tell). Hence, I thought that I was calling R itself when initialising the dll. I am using Baiers function R_proxy_evaluate_noreturn() because it seemed wiser to use code that was written by someone who knows what they are doing than roll my own! I don't understand enough about R IO functions to feel comfortable using them and am having trouble finding doco on them. I'm slowly learning about them, and the rest of R, by reading the code. Is there any doco on around on these and the R source in general? Thanks again for the rapid reply Simon Knapp