Parallel sessions to different hosts

Advertisement

nathans
Donor
Joined:
Posts:
3

Parallel sessions to different hosts

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

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Parallel sessions to different hosts

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).

Reply with quote

nathans
Donor
Joined:
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

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
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).

Reply with quote

Advertisement

You can post new topics in this forum