Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ilya Rabyy
  Where is Ilya Rabyy?
 Fountain Valley
 California - United States
 Ilya Rabyy
 To: Tom Cloud
  Where is Tom Cloud?
 Texas - United States
 Tom Cloud
Subject: RE: how Cancel subprogram
Thread ID: 209739 Message ID: 209741 # Views: 3 # Ratings: 1
Version: Visual FoxPro 9 SP2 Category: Forms
Date: Tuesday, December 30, 2008 5:24:00 PM         

> I need to be able to cancel a (running) subprogram from the form that initiated it.
> The form allows a user to read updated Project Member information from a website. Each member has a separate page. The subprogram first reads the Member Index (to get the URLs for each member page) and then reads and parses the Member information from each member page into a table. Sometimes the remote server hangs or the user will want to bail out for some reason and I'd like to provide that capability.
> I added a logical Property to the form named "llCancel".
> The subprogram, in its looping, checks back to the form to see if llCancel has been set .T.
IF mainform.llCancel

> ... and, if so, the loop is cancelled and the subprogram returns.
> I thought I was clever and thought I could use the same button to both Download and Cancel ??
> - The button on the form has Caption = "Download"
> - I had the caption change to "Cancel" and thought I could check in the Click event if the Caption had been changed to "Cancel" and, if so, set the llCancel property to .T.
> Apparently the button hangs until the called procedure (prg file) completes ??
> So I added a second button Captioned "Cancel", turned off the "Download" button and Enabled the "Cancel" button, etc.
> But that second button -- whose only function is to set the llCancel switch .T. on Click -- doesn't respond until the subprogram called by the Download button completes.
> I clearly have a misconception -- thought things were event driven and one button didn't need to wait until something initiated by another one was completed ??
> How do I send a signal to the executing subprogram to stop and return ?
> thanks,
> Tom

Hi Tom,

First off, there are Application.AutoYield property and DOEVENTS command (look 'em up in Help) that may prove being useful.

Second, I would rather make this procedure into that form's method rather than have it as a stand-alone PRG (even though - granted! - included into the project): this way you would have some more control over this procedure (IMHO).





how Cancel subprogram Posted by Tom Cloud @ 12/30/2008 5:03:02 PM
RE: how Cancel subprogram Posted by Ilya Rabyy @ 12/30/2008 5:24:00 PM
RE: how Cancel subprogram Posted by Tom Cloud @ 12/31/2008 2:38:18 PM
RE: how Cancel subprogram Posted by Ilya Rabyy @ 12/31/2008 4:35:16 PM