I have one SftpClient on which I sometimes do multiple operations simultaneously. Each of these operations happens at a separate thread (I'm using a Parallel.ForEach loop). I've read around here that SftpClient can handle this, and I have not detected any problem with SftpClient itself. But I'm using Ionic.Zlib.dll for zlib compression and it gives me "strange" exceptions when multiple operations occurs. I suspect that Ionic.Zlib.dll either has a problem with thread safety (I know it's not thread safe) or multiple operations at the same time. The exceptions I'm getting is a ArgumentOutofRange exception deep inside Ionic.Zlib.dll. Does anyone has any thoughts or experience with this? I have not had any troubles when using Ionic.Zlib.dll with single operations on a single thread.
I could create a separate SftpClient for each operation, but the operations consists of Exists() and small file transfers so the overhead of creating a new connection each time would be very big. Doing the operations synchronous takes forever. I've also given thought to creating a pool but I would rather not do that.
I could create a separate SftpClient for each operation, but the operations consists of Exists() and small file transfers so the overhead of creating a new connection each time would be very big. Doing the operations synchronous takes forever. I've also given thought to creating a pool but I would rather not do that.