I'm trying to async copy files from one drive to another using .NET 2.0 in a WinForms application. I've got this working in .NET 4.5 using this guide: http://msdn.microsoft.com/en-us/library/kztecsys(v=vs.110).aspx -- I'm looking for the .NET 2.0 equivalent of this (the 2.0 version in the guide deals with image processing).

Alternatively, are there any good frameworks out there that can handle this for me?

有帮助吗?

解决方案

async/await uses ThreadPool under hood. So if you want to copy file and hide proggress bar you can use tis code

    public delegate void InvokeDelegate();

    private void CopyFiles()
    {
        ....
    }

    public void HideProgressBar()
    {
        ...
    }

    void CopyFilesAsync(object sender, EventArgs e)
    {
        ThreadPool.QueueUserWorkItem(x =>
        {
            CopyFiles();
            BeginInvoke(new InvokeDelegate(HideProgressBar));
        });
    }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top