Disconnect Event Firing before DataReceived event - WeOnlyDo Discussion board

Disconnect Event Firing before DataReceived event (General questions)

by scott, Thursday, August 05, 2004, 21:00 (7194 days ago)

I'm working on a class that needs to execute a program on a server over an ssh connection. The problem I'm having is that the Disconnected event fires before I receive the data in the DataReceived event. If I set breakpoints in the code I can see that the DataReceived event fires, I just can't get access to it since the Disconnected event has already returned me back from my class. I would use the DataReceived event to capture the data, but some of the commands require 2 or 3 receive events before all of the data is received.

The code that I'm using is:

Private WithEvents ssh as New ssh()

Public Sub RunCommand()

with ssh
.Hostname = host
.Login = login
.Password = password
.Command = command
.Protocol = SupportedProtocols.SSHAuto
.Encryption = EncryptionMethods.Auto
.Connect
End With

do
'Don't do anything i just want to give the thread time to complete
until ssh.State = States.Disconnected

End Sub
In the Receive event I set a module level variable to the results of the command then raise an even in the disconnect event that returns the result to the calling app.

Private Sub ssh_DataReceivedEvent(ByVal Sender As Object, ByVal Args As WeOnlyDo.Client.SSH.DataReceivedArgs) Handles ssh.DataReceivedEvent) handles ssh.DataReceivedEvent

dim s as string = ssh.receive()
m_Results &= s

End Sub

Private Sub ssh_DisconnectedEvent(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles ssh.DisconnectedEvent

RaiseEvent CommandComplete(m_Results, m_Command)
m_Results =

End Sub

Any help would be appreciated.

Re: Disconnect Event Firing before DataReceived ev

by wodSupport, Thursday, August 05, 2004, 23:20 (7194 days ago) @ scott

Scott,

if you don't set Command property, but send the command after being connected, it will work correctly - right?

I would need to duplicate this problem to see exactly what's going on 'under the hood' if possible. Would it be too much to ask? Can you please send email to techsupport@weonlydo.com, and we'll try to see how to duplicate this problem and find the solution.

Thanks,
Kreso