Topic "Close session without destroying object"

Author Message
m.kunzendorf
[View user's profile]

Joined: 2013-12-11
Posts: 2
Location: Germany
Hi,

I am trying to use the Winscp.net assembly into an existing file transfer program written in vb.net.

I am wondering why no Close method exists inside the Session class to close the current session without disposing the complete object. Sometimes it is useful to close a session and reopen it again with other credentials.

To make some tests I have added a Close method to the source code of the assembly. It looks like this:

public void Close()
{
using (Logger.CreateCallstackAndLock())
{
Cleanup();
}
}

Any comments if this is suitable? Or do you see any bad side effects?

Best,
Michael
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Well, what is a problem about creating a new instance of Session? There is no measurable overhead.

Last edited by martin on 2014-01-08; edited 1 time in total
m.kunzendorf
[View user's profile]

Joined: 2013-12-11
Posts: 2
Location: Germany
In my case I had to replace an other FTP component in an existing bigger application. Creating new session instances would cause deeper changes in the program flow and application design. Due to time constrains I wanted to avoid this.

But you are right. Creating new session instances has no Performance Impact and from OO perspective, it is the cleaner solution.

Michael
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