0

I'm using

File.Copy(source, dest);

I need to know when this copy job is done processing so that it can move on to another task.

Is there any callback function I could use in this particular case?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
RoundOutTooSoon
  • 9,821
  • 8
  • 35
  • 52
  • possible duplicate of [How do I delay a vb.net program until a file operation completes?](http://stackoverflow.com/questions/437396/how-do-i-delay-a-vb-net-program-until-a-file-operation-completes) – John Boker Nov 30 '10 at 20:22
  • I've given you some code to help you out... – Achilles Nov 30 '10 at 20:33

4 Answers4

6

File.Copy is not asynchronous. It has completed when the call finishes.

Moo-Juice
  • 38,257
  • 10
  • 78
  • 128
2

File.Copy is blocking so execution should wait until the operation has complete.

Rohan West
  • 9,262
  • 3
  • 37
  • 64
1

Isn't File.Copy a blocking method? It should wait on that line until the copy of the file is complete then continue execution.

John Boker
  • 82,559
  • 17
  • 97
  • 130
0

Here is some code to do what you need...cause I'm awesome that way :-)

dim FileCopyDelegate as new Delegate = addressof File.Copy

dim oListOfParams as new List(of string)

oListOfParams.add(source)
oListOfParams.add(destination)

FileCopyDelegate.begininvoke(oListOfParams, addressof CallBackMethod) 'creates an async thread to do the file copy
Achilles
  • 11,165
  • 9
  • 62
  • 113