Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Stopping app in recursive loop?

Posted on 1998-01-30
5
Medium Priority
?
147 Views
Last Modified: 2010-04-04
Can someone tell me how to stop an application when a recursive loop is running? For example, if I am recursively reading through an entire disk (which takes a long time), and I click the "Close" button, nothing happens.  I want to be able to stop everything and just shut down. I thought I had this figured out, but to no avail. :-)  
0
Comment
Question by:jexd99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Accepted Solution

by:
d003303 earned 150 total points
ID: 1358031
Yo,

define a global break-flag that is false initially. Set it to true in the OnCloseQuery-event of the form.
In your recursive loop, add the line Application.ProcessMessages and check for the break-flag. Exit the loop if the flag is true.

Slash/d003303
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1358032
You can do it with threads. -Look at the sorting example taht D3 or D2 has in the \demos\threads dir.
If you want to terminate a thread you just call the .Terminate method and that means taht your recursive proc will also terminate.

Good luck!
Matvey
0
 

Expert Comment

by:michael2010898
ID: 1358033
If the program responds to the button click you
can use application.terminate
If not then use thread for the procedure and when the user
clicks the button use .Terminate if you want to stop
the procedure or use .Supend to supend it and then you will be
able to continue it with .Resume.


0
 
LVL 4

Expert Comment

by:d003303
ID: 1358034
Threads might be a better solution than mine. You could also recurse through several disks the same time, just start a second instance of the thread object. Like Matvey said, the sorting example is worth a look.
If want to use threads, don't hesitate to reject my answer.

Slash/d003303
0
 

Author Comment

by:jexd99
ID: 1358035
Thanks for the info. :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question