Streams in .net

I have a simple winforms application example in which I select a directory in the selection list and click a button to scroll through the directory and copy each file to the directory in a different directory.

I want to make a copy of the file in the background thread to avoid GUI blocking.

I am looking for the simplest solution for:

  • Create a background thread
  • Pass the source and recipients to
  • Get a callback for progress so that I can show a progress bar in the GUI thread.
+4
source share
2 answers

I would recommend using the BackgroundWorker class.

An example .

+7
source

In addition to the answer above, I would add that BackgroundWorker is perfect for this, as it can also give you updates. Just make sure that you prevent re-inclusion - you need to prevent a situation where the user can restart the background worker before it is completed.

+2
source

All Articles