c# transfer files in parallel
Hello ewary one.
I have a problem with transfer files in parallel. When i do that - this look all ok, but indeed nope. If i start one task - File's transfer worked OK, but if i try do more then 1 session in parallel - session.FileTransferProgress in all Task return 100%, but File's loads in not all session in fact. What wrong i do?
PS Without parallel - all works fine.
I have a problem with transfer files in parallel. When i do that - this look all ok, but indeed nope. If i start one task - File's transfer worked OK, but if i try do more then 1 session in parallel - session.FileTransferProgress in all Task return 100%, but File's loads in not all session in fact. What wrong i do?
PS Without parallel - all works fine.
await Task.Run(() => Parallel.ForEach(storeList, store => { if (store.CheckBox == true) { parallel_options.CancellationToken.ThrowIfCancellationRequested(); using (Session session = new Session()) { options.HostName = store.IpForFiles; session.Timeout = TimeSpan.FromSeconds(10); session.FileTransferProgress += SessionFileTransferProgress; session.Open(options); Console.Write("\n" + store.Num + " START!"); try { foreach (var path in FilesList) { bool fileExists = session.FileExists("test_for_upload/"); if (fileExists == true) { var transferResult = session.PutFiles(path.PathFile, remoutePath); Console.Write("\n" + store.Num + " EXISTS"); } else { session.CreateDirectory("test_for_upload/"); var transferResult = session.PutFiles(path.PathFile, remoutePath); Console.Write("\n" + store.Num + " CREATER"); } } Console.Write("\n" + store.Num + " FINISH!"); session.Close(); } catch (Exception err) { MessageBox.Show(err.Message); } finally { } } } else { } }));