MTmyVFP Version 3 - Project Home Page Requires VFP 9 (but could probably easily be modified to work in earlier versions). MTmyVFP is written completely in FoxPro and all source code is included.
Test and use the examples in the included simple form, or, just create and run from the foxpro command window:
<make sure you're in whatever directory you installed to>
oThreadMgr=NEWOBJECT("ThreadManager","threads.fxp")
oThreadMgr.CreateThread("MyThreadFunc","myparameter",[MESSAGEBOX("My thread done!","Result")],[? "processing..."])
Param 1 - the code that will run in a background thread
Param 2 (optional) - any parameter you want to pass to your code
Param 3 (optional) - code that will run when your thread completes
Param 4 (optional) - code that will run in the foreground while your thread is processing (you could possibly add a progress bar here like the one in ctl32_progressbar in VFPX)
Other methods:
oThreadMgr.SendMsgToStopThreads() - stop the threads
oThreadMgr.SuspendThreads() - pause the threads
oThreadMgr.ResumeThreads() - resume the threads
--------
Calvin Hsia's original source and background info:
http://blogs.msdn.com/calvin_hsia/archive/2006/05/23/605465.aspx For more elaborate examples of using this class see:
VFPWebCrawler -
http://www.codeplex.com/vfpwebcrawlerand
Thread Test by Fernando Bozzo (VFP 8,9)
-
http://www.portalfox.com/articulos/archivos/bozzo/Test_Threads.zip