I\'m not sure if the Title is a good description of this issue or not. Essentially what I have is a WinForm app that retrieves a list of files from a folder into a ListView,
You could offload the long-running operation to a ThreadPool
thread, by using async/await and the handy Task.Run method:
transferResult = await Task.Run(() => session.PutFiles(readyFile, destFile, false, transferOptions));
...and:
transferResult = await Task.Run(() => session.PutFiles(triggerFile, destFile, false, transferOptions));
You should also add the async modifier in the event handler, in order to enable the await operator.
Important: Avoid doing anything UI related in the offloaded method. If you want to communicate with the UI during the operation, for example for progress reporting, use the Progress