I have been trying to come up with an elegant solution to something but have not had any success. Some suggestions and comments would be most welcome. This is the scenario:
1. Application is single threaded
2. Makes call to a procedure that is very intensive (say a recursive scan of a directory tree)
Now I dont want the 2. call to return until it has completed what it is doing. However as it utilises 100% CPU the main application suffers. So how do I work around this?
Possible Solutions
a) Provide a callback in the 2. procedure so that the application can do something about things. Say call Application.ProcessMessages
This is OK, but it would be nice if the caller of 2. did not have to do anything.
So I guess my question is. How do I change 2 so that it:
- Co-Operates nicely with its caller in terms of resource usage
- Blocks until it finishes
Is it somehow possible to kick off a thread in 2. but still have it block until it finishes what it has to do?
I hope this is clear. Any comments, suggestions welcome.
----------------------------------------------------------------------
Donovan J. Edye [www.edye.wattle.id.au]
Namadgi Systems [www.namsys.com.au]
Voice: +61 2 6285-3460
Fax: +61 2 6285-3459
TVisualBasic = Class(None);
Heard just before the 'Big Bang': "...Uh Oh...."
----------------------------------------------------------------------
GXExplorer [http://www.gxexplorer.org] Freeware Windows Explorer
replacement. Also includes freeware delphi windows explorer components.
----------------------------------------------------------------------