From sleepingwell at gmail.com  Fri Dec  9 10:18:56 2005
From: sleepingwell at gmail.com (Simon Knapp)
Date: Fri, 9 Dec 2005 20:18:56 +1100
Subject: [Rd] Blocking problem with embeded R (windows)
Message-ID: <4f8ec3aa0512090118h6c7700d3v1c2a1a5278aa9f4d@mail.gmail.com>

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



[Rd] Blocking problem with embeded R (windows)
Simon Knapp