Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions src/Renci.SshNet/Abstractions/ThreadAbstraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ public static void Sleep(int millisecondsTimeout)

public static void ExecuteThreadLongRunning(Action action)
{
if (action == null)
throw new ArgumentNullException("action");

#if FEATURE_THREAD_TAP
var taskCreationOptions = System.Threading.Tasks.TaskCreationOptions.LongRunning;
System.Threading.Tasks.Task.Factory.StartNew(action, taskCreationOptions);
#else
var thread = new System.Threading.Thread(() => action());
thread.Start();
new System.Threading.Thread(() => action())
{
IsBackground = true
}.Start();
#endif
}

Expand Down
3 changes: 2 additions & 1 deletion src/Renci.SshNet/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,8 @@ public void Connect()
_messageListenerCompleted.Reset();

// Start incoming request listener
ThreadAbstraction.ExecuteThread(() => MessageListener());
// ToDo: Make message pump async, to not consume a thread for every session
ThreadAbstraction.ExecuteThreadLongRunning(() => MessageListener());

// Wait for key exchange to be completed
WaitOnHandle(_keyExchangeCompletedWaitHandle);
Expand Down