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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to do multi-threading in FoxPro 7.0?

Status
Not open for further replies.

CosmoGreco

Programmer
Sep 16, 2002
13
0
0
US
Dear FoxPro colleagues,

I really enjoy programming in FoxPro - since its very first release and before - the times that Dbase II and Clipper were introduced. Visual version 7.0 is great, despite having some bugs to be fixed and it’s my preferred programming tool.

I can't help though being a little bit disappointed to not be able to do Windows multi-treading in my applications.

I believe that any modern language should have the capabilities to do it.

Perhaps it is due to my lack of knowledge in this area of FoxPro that I can’t make it perform such task and maybe someone could teach me a little bit about it.

Let's say I'm processing records in a database or copying files to the disk. At the same time I populate a List Box with the files names being copied so the user can visualize what file is being processed.

Here is the problem: during the process of copying this files, FoxPro doesn't give the control back to the user until it is done with the task - e.g. let's say at the same time the List Box in being populate, I want to have the control to scroll up or down it to visualize de List Box contents or if I wish, be able to resize the form.

The solution I use in other languages, like C/C++ or C# and even in Visual Basic, is to create a Windows thread and put that process running inside it. This way I can do other things with my form while the process is being completed.

Appreciate any information on this.

Regards,
Cosmo
cosmogreco@hotmail.com
 
Cosmo,

There was some article about multi-threading in VFP 6.0/7.0 couple months ago in FoxTalk or in FoxPro Adviser magazine. (Both of them are worth subscribing, somewhat steepy cost notwithstanding).

Regards

Ilya
 
CosmoGreco!

Please read the help of DOEVENTS command.

Here is a sample that may help you what you want to achieve.

- Create a simple form and add a property lInLoop

- Add two command buttons and name them cmdStartProcess and cmdCancel

- Add follwing code in the click event of cmdStart

ThisForm.lInLoop = .T.

LOCAL lnCounter AS Integer

lnCounter = 1
DO WHILE ThisForm.lInLoop
WAIT WINDOW NOWAIT 'Counter = ' + LTRIM(STR(lnCounter))
lnCounter = lnCounter + 1
DOEVENTS
ENDDO
WAIT WINDOW 'I am out of loop'

- Add following code in the click event of cmdCancel

ThisForm.lInLoop = .F.

- Now run the form and click cmdStartProcess button

- Now you can change the form size or whatever you want to do. Clicking cmdCancel will terminate the process.

Hope this will help you.
 
IRABYY

There was some article about multi-threading in VFP 6.0/7.0 couple months ago in FoxTalk or in FoxPro Adviser magazine. (Both of them are worth subscribing, somewhat steepy cost notwithstanding).

You can get an online free membership for thirty days here:


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top