Topic "Parallel sessions to different hosts"

Author Message
nathans
[View user's profile]
Donor
Joined: 2014-12-17
Posts: 3
Hello,
What is the correct way to initiate multiple sessions each connecting to a different host? I am running some tests now with an application that starts 4 threads, each one creating a new instance of SessionOptions & WinSCP.Session(), and then calling PutFiles to send files to 4 different servers. It seems in some cases they run in parallel, but in other cases some threads will hang.

Will creating a new Session in each thread allow parallel calls to the underlying winscp.exe ?
Is this the safest/best performing strategy?

Thanks for any advice
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
The WinSCP .NET assembly interface is synchronous. So you need to have separate threads for every session, if you do not want them to blocked each other.
Also there's no problem having multiple Session instances running in parallel (in different threads).
nathans
[View user's profile]
Donor
Joined: 2014-12-17
Posts: 3
Thank you very much for the reply.

This statement in documentation makes me think I may be doing something wrong:

ref - https://winscp.net/eng/docs/library_session
"The class is locked against concurrent accesses from multiple threads. Though you can use several instances of the class in parallel, even from different threads."


So, I thought that I may be hitting some contention there. I will try to reproduce in small project.

Thanks again
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
nathans wrote:
This statement in documentation makes me think I may be doing something wrong:

ref - https://winscp.net/eng/docs/library_session
"The class is locked against concurrent accesses from multiple threads. Though you can use several instances of the class in parallel, even from different threads."

So, I thought that I may be hitting some contention there. I will try to reproduce in small project.

I'd appreciate, if you suggest better wording (obviously, I'm not a native English speaker).
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License