Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Renci.SshNet/ShellStream.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@
using System.Threading;
using System.Threading.Tasks;

using Renci.SshNet.Abstractions;
using Renci.SshNet.Channels;
using Renci.SshNet.Common;

Expand DownExpand Up@@ -44,6 +45,11 @@ public class ShellStream : Stream
/// </summary>
public event EventHandler<ExceptionEventArgs>? ErrorOccurred;

/// <summary>
/// Occurs when the channel was closed.
/// </summary>
public event EventHandler<EventArgs>? Closed;

/// <summary>
/// Gets a value indicating whether data is available on the <see cref="ShellStream"/> to be read.
/// </summary>
Expand DownExpand Up@@ -894,6 +900,12 @@ private void Session_Disconnected(object? sender, EventArgs e)
private void Channel_Closed(object? sender, ChannelEventArgs e)
{
Dispose();

if (Closed != null)
{
// Handle event on different thread
ThreadAbstraction.ExecuteThread(() => Closed?.Invoke(this, EventArgs.Empty));
}
}

private void Channel_DataReceived(object? sender, ChannelDataEventArgs e)
Expand Down