Question

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?

Was it helpful?

Solution

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));
        });
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top