Determine when main event loop is waiting for a wxExecute process

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
richard_examion
Knows some wx things
Knows some wx things
Posts: 43
Joined: Wed Feb 27, 2019 7:17 am

Determine when main event loop is waiting for a wxExecute process

Post by richard_examion »

Hi there,
I would like to know, if it is possible to determine when the main event loop is waiting for a process to be finished after:

Code: Select all

wxExecute ("anotherProcess.exe", wxEXEC_SYNC);
was called.
So far I use

Code: Select all

wxEventLoop::GetActive ()->IsMain ()
in ::OnIdle (wxIdleEvent &event) function to determine when a ModalDialog is opened, however with another process this won´t work...

Thanks
Richard
User avatar
doublemax
Moderator
Moderator
Posts: 18180
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Determine when main event loop is waiting for a wxExecute process

Post by doublemax »

As wxExecute with wxEXEC_SYNC is a blocking call, do you even receive any events during that time?

If yes, can't you just set a flag before the call, and clear if afterwards?
Use the source, Luke!
richard_examion
Knows some wx things
Knows some wx things
Posts: 43
Joined: Wed Feb 27, 2019 7:17 am

Re: Determine when main event loop is waiting for a wxExecute process

Post by richard_examion »

Yes, I do receive idle events - this is true for instance:

Code: Select all

wxEventLoop::GetActive ()->IsRunning ()
!

Probably, a flag seems the best solution even though I don´t like things like that...
richard_examion
Knows some wx things
Knows some wx things
Posts: 43
Joined: Wed Feb 27, 2019 7:17 am

Re: Determine when main event loop is waiting for a wxExecute process

Post by richard_examion »

By the way, is it possible to wake up from that idle loop, even though the wxExecute (wxEXEC_SYNC) process is not quite finished yet?
User avatar
doublemax
Moderator
Moderator
Posts: 18180
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Determine when main event loop is waiting for a wxExecute process

Post by doublemax »

Maybe you should derive a class from wxProcess, create an instance, and start the process with wxEXEC_ASYNC (while passing a pointer to wxProcess) to track its lifetime. The "exec" sample that comes with wxWidgets shows how to do that.
Use the source, Luke!
richard_examion
Knows some wx things
Knows some wx things
Posts: 43
Joined: Wed Feb 27, 2019 7:17 am

Re: Determine when main event loop is waiting for a wxExecute process

Post by richard_examion »

Thanks for that hint, I will try to figure it out!
Post Reply