BeginUploadFile getting ((Renci.SshNet.Common.SftpPermissionDeniedException)(exception)) exception = {"The requested operation cannot be performed because there is a file transfer in progress."}

Sep 27, 2013 at 2:05 PM
I am using the Version 2013.4.7.0.

I am trying to use the async functionality to upload files concurrently.

I followed the example at https://sshnet.codeplex.com/wikipage?title=ExampleSftpMultipleUploadDownload

The only difference is I am using PrivateKeyFile to connect with "aes128-cbc" encryption .

I keep getting the following error at the second BeginUploadFile:
((Renci.SshNet.Common.SftpPermissionDeniedException)(exception))
exception = {"The requested operation cannot be performed because there is a file transfer in progress."}

I am not sure if what I am missing. Below is a snippet of the code i am using:
_keyFile  = new PrivateKeyFile(@"Path to private key in openSSH","passkey");
        _keyFiles = new[] { _keyFile };
        _connectionInfo = new PrivateKeyConnectionInfo("host", "account", _keyFiles);
        foreach (var d in _connectionInfo.Encryptions.Where(p => p.Key != "aes128-cbc").ToList())
        {
            _connectionInfo.Encryptions.Remove(d.Key);
        }

        _client = new SftpClient(_connectionInfo);
        _client.Connect();
        _client.ChangeDirectory("IncomingData");



                var mem2 = File.OpenRead (@"Path to file 1");
                var mem3 = File.OpenRead(@"Path to file 2");

                var asynch = _client.BeginUploadFile(mem2, Path.GetFileName(@"Path file 1"),true, null,null);
                var asynch2 = _client.BeginUploadFile(mem3, Path.GetFileName(@"path file 2"),true,null,null);


                while (!asynch.IsCompleted && !asynch2.IsCompleted)
                {
                    Thread.Sleep(100);
                }

                _client.EndUploadFile(asynch);
                _client.EndUploadFile(asynch2);
Any ideas what I am missing?