Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
These properties of the _VFP Application Object
, added in VFP 6 SP3, return the Windows ProcessID and ThreadID.
nThreadID = _VFP.ThreadID
nProcessID = _VFP.ProcessID
Starting a program in Windows creates a process. Each process has a numeric ID associated with it. (Go into the Task Manager, select the Processes tab, and you’ll see the Process ID, or PID). Within each process, there is at least one thread. A thread shares the process’ virtual address space and system resources. A single-threaded application has one thread; a multithreaded application has many threads that can appear to run at the same time using preemptive multitasking (available in Windows NT and later). VFP is, practically speaking, a single-threaded application for its main logic, although it does spawn a couple of “helper” threads on occasion.
What does this mean to your application? Mostly, it explains how it runs, and you don’t have to worry about it. Now, if you’re writing COM objects, you’ll likely need to understand a little more about it. For more information on this, see the Help file topic, “Scalability and Multithreading.” Using the ProcessID and ThreadID properties can help you debug COM objects. You can also pass these values to certain Windows APIs for more functionality, for example, to kill a process.
nThreadID = _VFP.ThreadID
nProcessID = _VFP.ProcessID