How it works...

When the Windows form opens up for the first time, you will see that the timer label defaults to Timer Stopped. Click on the Copy Files Async button to start the copy process:

When the application has finished processing, you will see that the large files have been copied to the destination folder:

While the copy process is running, your Windows form remains active and responsive. The timer label also continues to count. Usually, with processes such as these, the form would be unresponsive:

When the files have finished copying, the timer label will display the duration of the async copy process. A fun experiment is to play around with this code to see how much you can optimize it to improve the copy speed:

The Windows form not only remains responsive, but also allows you to cancel the process whenever you like. When you click on the Copy Files Async button, the text changes to Cancel Async Copy:

Clicking on the Cancel button or sets the CancellationTokenSource object to canceled, which in turns stops the async file copy process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.252.204