SftpClient Disconnected event

Jan 31, 2012 at 9:24 AM

After calling  SftpClient.Disconnect(); method,  testing   IsConnected  value i expected the value go from true to false but this seems not occur even waiting a certain time:

                    _sftp.Disconnect();
                    while (_sftp.IsConnected)
                    {
                        Console.Write("\n sftp disconnecting... : ");
                        System.Threading.Thread.Sleep(200);

                    }
                    Console.Write("\n sftp server disconnected! : ");

    _sftp.IsConnected value is keeping True

How  can i test correctly the Disconnected condition with sftpClient,  maybe have i done  something wrong?

Any suggestions?

Thank you.

Coordinator
Jan 31, 2012 at 8:44 PM

The best approach would be to handle an disconnect event but I did not provide such events so far.

 

If you have source version you can easly add an event and raise it from protected OnDisconnecting method, this is the one that called when client disconnecting.

 

Hope it helps.

 

Thanks,

Oleg

Feb 1, 2012 at 7:18 AM

Yes, just for this reason i think  the public method  IsConnected()  exposed by SftpClient class is not working as well,

maybe a possible bug?   Thanks.

Coordinator
Feb 1, 2012 at 1:10 PM

ok,

 

I'll try to take a look at it as soon as I have some free time.

 

Thanks,

Oleg