during a long connection I get following exceptions:
```
System.ObjectDisposedException: Das SafeHandle wurde geschlossen.
bei Renci.SshNet.Session.WaitHandle(WaitHandle waitHandle) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Session.cs:Zeile 642.
bei Renci.SshNet.Channels.Channel.WaitHandle(WaitHandle waitHandle) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Channels\Channel.cs:Zeile 496.
bei Renci.SshNet.Channels.ChannelSession.Open() in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Channels\ChannelSession.cs:Zeile 52.
bei Renci.SshNet.ShellStream..ctor(Session session, String terminalName, UInt32 columns, UInt32 rows, UInt32 width, UInt32 height, Int32 maxLines, IDictionary`2 terminalModeValues) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\ShellStream.cs:Zeile 73.
bei Renci.SshNet.SshClient.CreateShellStream(String terminalName, UInt32 columns, UInt32 rows, UInt32 width, UInt32 height, Int32 bufferSize, IDictionary`2 terminalModeValues) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\SshClient.cs:Zeile 384.
bei Renci.SshNet.SshClient.CreateShellStream(String terminalName, UInt32 columns, UInt32 rows, UInt32 width, UInt32 height, Int32 bufferSize) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\SshClient.cs:Zeile 366.
```
and
```
System.ObjectDisposedException: Das SafeHandle wurde geschlossen.
bei System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
bei Microsoft.Win32.Win32Native.SetEvent(SafeWaitHandle handle)
bei System.Threading.EventWaitHandle.Set()
bei Renci.SshNet.ShellStream.Channel_DataReceived(Object sender, ChannelDataEventArgs e) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\ShellStream.cs:Zeile 739.
bei Renci.SshNet.Channels.Channel.OnData(Byte[] data) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Channels\Channel.cs:Zeile 289.
bei Renci.SshNet.Channels.Channel.OnChannelData(Object sender, MessageEventArgs`1 e) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Channels\Channel.cs:Zeile 590.
bei System.EventHandler`1.Invoke(Object sender, TEventArgs e)
bei Renci.SshNet.Session.OnChannelDataReceived(ChannelDataMessage message) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Session.cs:Zeile 1392.
bei Renci.SshNet.Session.HandleMessage(ChannelDataMessage message) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Session.cs:Zeile 1034.
bei CallSite.Target(Closure , CallSite , Session , Object )
bei Renci.SshNet.Session.HandleMessageCore(Message message) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Session.NET40.cs:Zeile 20.
bei Renci.SshNet.Session.MessageListener() in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Session.cs:Zeile 1589.
```
The application opens a ssh connection and opens/parses a ShellStream every 10 seconds.
IsConnected stays true.
I currently can't test the current beta since it has issues with closing the channel after
disposing the ShellStream.
No errors or unusual log entries on the server side.
Comments: ** Comment from web user: drieseng **
```
System.ObjectDisposedException: Das SafeHandle wurde geschlossen.
bei Renci.SshNet.Session.WaitHandle(WaitHandle waitHandle) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Session.cs:Zeile 642.
bei Renci.SshNet.Channels.Channel.WaitHandle(WaitHandle waitHandle) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Channels\Channel.cs:Zeile 496.
bei Renci.SshNet.Channels.ChannelSession.Open() in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Channels\ChannelSession.cs:Zeile 52.
bei Renci.SshNet.ShellStream..ctor(Session session, String terminalName, UInt32 columns, UInt32 rows, UInt32 width, UInt32 height, Int32 maxLines, IDictionary`2 terminalModeValues) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\ShellStream.cs:Zeile 73.
bei Renci.SshNet.SshClient.CreateShellStream(String terminalName, UInt32 columns, UInt32 rows, UInt32 width, UInt32 height, Int32 bufferSize, IDictionary`2 terminalModeValues) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\SshClient.cs:Zeile 384.
bei Renci.SshNet.SshClient.CreateShellStream(String terminalName, UInt32 columns, UInt32 rows, UInt32 width, UInt32 height, Int32 bufferSize) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\SshClient.cs:Zeile 366.
```
and
```
System.ObjectDisposedException: Das SafeHandle wurde geschlossen.
bei System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
bei Microsoft.Win32.Win32Native.SetEvent(SafeWaitHandle handle)
bei System.Threading.EventWaitHandle.Set()
bei Renci.SshNet.ShellStream.Channel_DataReceived(Object sender, ChannelDataEventArgs e) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\ShellStream.cs:Zeile 739.
bei Renci.SshNet.Channels.Channel.OnData(Byte[] data) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Channels\Channel.cs:Zeile 289.
bei Renci.SshNet.Channels.Channel.OnChannelData(Object sender, MessageEventArgs`1 e) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Channels\Channel.cs:Zeile 590.
bei System.EventHandler`1.Invoke(Object sender, TEventArgs e)
bei Renci.SshNet.Session.OnChannelDataReceived(ChannelDataMessage message) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Session.cs:Zeile 1392.
bei Renci.SshNet.Session.HandleMessage(ChannelDataMessage message) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Session.cs:Zeile 1034.
bei CallSite.Target(Closure , CallSite , Session , Object )
bei Renci.SshNet.Session.HandleMessageCore(Message message) in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Session.NET40.cs:Zeile 20.
bei Renci.SshNet.Session.MessageListener() in c:\Users\srinkes\Desktop\Projects\XXX\Renci.SshNet\Session.cs:Zeile 1589.
```
The application opens a ssh connection and opens/parses a ShellStream every 10 seconds.
IsConnected stays true.
I currently can't test the current beta since it has issues with closing the channel after
disposing the ShellStream.
No errors or unusual log entries on the server side.
Comments: ** Comment from web user: drieseng **
I still have not been able to reproduce the issue, but I commit a few small changes that should improve the odds of not hitting the ObjectDisposedException.
Note that I do not consider these changes a real fix as we'd have to introduce more synchronization for that.
The problem is that we're disposing the WaitHandle instances, but our event handlers that use these WaitHandle instances are getting triggered after the dispose of the WaitHandle instances.
I've now moved the unsubscription up, but the real fix would be to synchronize the dispose and the set of the WaitHandles. Before I go down that road, I'll still like to know the effect of the changes I committed today.
Can you build from SVN, and try again ?