I
I
Ilya2012-10-27 19:50:36
Backup
Ilya, 2012-10-27 19:50:36

How to make a stream when copying files?

I'm trying to copy files with a progress bar. Everything works in principle, but the form still hangs when copying. Can that not so made at creation of a flow. Can anyone help?
The source itself is here - pastebin.com/kNkRWMMV
PS If necessary, I can lay out the project

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2012-10-27
@WNeZRoS

InCp add = new InCp(cp);
this.Invoke(add, new object[] { path });

With this code, you start copying on the interface thread.
For such a task, it would be appropriate to use a BackgroundWorker, there are built-in methods for updating data in the UI thread.

H
hack2root, 2012-11-01
@hack2root

BackgroundWorker has no built-in methods for updating data on the UI thread.
I propose my working version for working with BackgroundWorker:
pastebin.com/wJpqrKqu
Code for inclusion in WinForms
pastebin.com/Ck7KPxd8
Example of use in the System.Windows.Forms child class:
pastebin.com/J7ygJKx1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question