Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to interrupt a running VFP app without having VFP interrogating an outside file, device or other 4

Status
Not open for further replies.

dkean4

Programmer
Feb 15, 2015
282
US
I know how to use a timer to trigger an occasional interrupt like... "Is there a file named 'xxx.txt' in some subdirectory". But now I need some "shell" or another way to flag a running VFP app so that the user can use his/her app without interruption. Can 2 independent apps be running concurrently while one passes occasional flags? I do not want the user to be aware, "Yoh, dude, I need to tend to something else for a moment. I'm stopping you for the next 15 seconds"

Any help would be very appreciated.

Dennis Kean


Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Nigel Gomm

Please send me some working code, if you have any, concerning DDE communications between two EXE's. I have looked into that in the past and would love to do a few tests.


Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Yes, of course, there doesn't exist a vfptts.exe. I chose the name so it alone already is suggesting to you that it is an EXE doing TTS programmed in VFP. Thanks for posting the code, that plus a bit of parameterization is all you need in a separate EXE and already you don't wait for the speak to finish.

All you would have needed to tell is that you make a call to something that is executing synchronously, i.e. like any VFP code execution will only continue when that call returns. It's the norm, but usually a single command or function doesn't take the time it takes to speak a text.

If you want to start something and still go on in your code with the rest of the application, RUN /N is one solution if that task can be done by a separate process.

Another way of doing something almost parallel is have a timer that you setup to execute in 1ms by Interval=1, for example, and in it's Timer event then stops itself, a run once timer.

When you initialize it, that's being done with it, and your code continues. When that timer runs, it first should disable itself and never re-enable a next timer event to happen. Well, a run-once timer. But I guess when you do the speak method of the sapi.spvoice in the timer event your normal code and events still become less responsive, as VFP isn't multithreaded, a timer event interrupts anything that runs and that only continues after the timer finishes. So it's still blocking. That's why a VFP timer also isn't actual multithreading.

But in another process that's even not needing a timer. What's unnatural about VFP is that RUN by default waits for the EXE you run to finish, RUN /N should be the default. If you use Windows API CreateProcess() waiting for that created process to finish needs an extra call to WaitForSingleObject, the object being that other process. So actually in multiple processes parallelism is the default and I don't see a more complex need in your case.

Chriss
 
Chris Miller

Great and clear ideas. I am familiar with RUN /N. I use the following quite a lot:

Code:
#define SW_NORMAL 1
#define SW_MINIMIZED 2
#define SW_MAXIMIZED 3

oWSShell = CREATEOBJECT("WScript.Shell")
oWSShell.Run("C:\WINDOWS\system32\VFPTTS.exe",SW_MINIMIZED,.T.)

It seems to come back quicker, although I'm not certain.

Anyway, thank you for the follow-through. You rock, Chris. For your kindness, patience, and effort, you deserve another star.


Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top