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

Threading Question

Status
Not open for further replies.

ddvlad

Programmer
Mar 12, 2003
71
RO
Hi, everyone!

I have recently been faced with using an algorithm that kinda hogs the entire CPU. If the user tries to do anything during the running of the program, the computer hangs. I know I can solve this with threading, but I'm not quite sure how. As I see it, I should make a thread for the main algorithm and one to respond to the user events. Any thoughts or help anyone can offer me? I would be infinitely grateful.

Thanks in advance,
Vlad.
 
That depends.
If it is a lengthy and resource consuming (i.e. processing time) operation maybe it is better to run your operation in another thread (in order not to block the GUI thread) but forbid the user to do anything else. For example, you can perform your operation in background and present the user with a form which displays feedback (progress, operation details, etc) which has a "Cancel" button on it. This is a good ideea and the main reason is that allowing the user to perform some more actions while that operation is in progress might cause the computer to stop responding.

Another ideea is to attempt to improve that algorithm, if possible.

Please provide more details in order to narrow down the solution space [wink]


P.S.: You might wanna check
 
I am basically aiming to securely delete a file by overwriting its contents before deleting it. It wouldn't give the user a cancel option. As it is right now, any click outside the program window while shredding hangs the box. A modal progress form is there already, but still without result. Even right clicking the desktop results in catastrophy (or maybe it isn't that dramatic, but Windows still hangs...).
 
You're writing over the file? There are command line programs that do that. Make a file completely unrecoverable. I don't know any offhand but you might want to google it and run that app in a separate thread.

The other option: Create a listing of files that need to be shredded and perform the shredding overnight when the computer is not in use.
 
Idea is to create a Windows application specifically for that purpose. I've seen many before and need to do this for a quick-and-dirty project. I just don't want it that dirty ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top