Close session without destroying object

Advertisement

m.kunzendorf
Joined:
Posts:
2
Location:
Germany

Close session without destroying object

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

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: Close session without destroying object

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

Reply with quote

m.kunzendorf
Joined:
Posts:
2
Location:
Germany

Re: Close session without destroying object

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

Reply with quote

Advertisement

You can post new topics in this forum