|
-
Jun 11th, 2007, 06:00 AM
#1
[2005] How to tell when a file copy has finished
Hi All,
I have a form that starts a background worker when it loads and basically acts as a progress form to show how far the file copy has got (it copies various files to various locations so I dont want to use the standard windows copy dialog box cos I'll have loads appearing). If the user clicks cancel or closes the form I want the operation to cancel, which I have done by testing whether or not the worker is cancellationpending before each file copy starts. So if it is cancel pending then I just exit the sub and close the form. In some cases though if there are a lot of files to copy then this means files will still be being copied in the background without the user knowing because the form has closed. So basically I want a way of being able to keep the form open (displaying "cancelling..." or something similar) temporarily until the copy has finished. Or a way to cancel the file copy immediatley would be even better. I have tried using the worker.isbusy property but this doesnt work, it just says the worker isnt busy as soon as the form closes even if there are still files being copied.
Thanks
Chris
-
Jun 11th, 2007, 05:08 PM
#2
Re: [2005] How to tell when a file copy has finished
anyone?
-
Jun 12th, 2007, 01:24 AM
#3
Re: [2005] How to tell when a file copy has finished
Don't close the form until the task has finished. In the Click event handler of the Cancel button just disable the button so it can't be pressed again and then cancel the BackgroundWorker. You then close the form in the BackgroundWorker's RunWorkerCompleted event handler, so it happens when the operation completes, cancelled or not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|