2009/11/1 OvermindDL1 <[email protected]>:
> But it still seems to me that if you want to launch another
> application, why does the process creation call block, thus requiring
> you to do odd things like fork or use threads if you want to keep
> things active? Is there not an asynchronous call to create a process
> as is the default in Windows?
>
The normal way in unix to create a new process is fork() and then one
of the exec() functions. None of them block. System does block,
because it returns the exit value of the application that you execute.
To come back to the original question: it depends a bit which is the
best approach. In any case, it is generally a good idea to keep the
time spent within a Wt event loop short, for the same reason as it is
not nice to do long computations in any GUI system's event loop: the
GUI locks up for a long time. So what are the alternatives?
- if you're not interested in reporting progress or termination of the
processing: start a new process in the background and forget about it.
- if you want to report progress, realize that this does not work:
void startCalculationSlot()
{
while (!done) {
doSome();
progressbar->update(...);
}
}
GUI updates are only propagated after you return control to Wt's event
loop. (with a few exceptions)
- You can report progress by using a WTimer. Set the timeout interval
to e.g. 1 second, and query the calculation process to see how far it
is in the slot; report it back to the user.
- You can report progress by using server push. Start a new thread,
which reports progress from time to time using Wt's server push
mechanism (see the simplechat example)
Regards,
Wim.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest