Skip to content

Commit c392766

Browse files
committed
Added ExecuteThreadLongRunning.
1 parent 178512c commit c392766

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Renci.SshNet/Abstractions/ThreadAbstraction.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,23 @@ public static void Sleep(int millisecondsTimeout)
1919
#endif
2020
}
2121

22+
public static void ExecuteThreadLongRunning(Action action)
23+
{
24+
#if FEATURE_THREAD_TAP
25+
var taskCreationOptions = System.Threading.Tasks.TaskCreationOptions.LongRunning;
26+
System.Threading.Tasks.Task.Factory.StartNew(action, taskCreationOptions);
27+
#else
28+
var thread = new System.Threading.Thread(() => action());
29+
thread.Start();
30+
#endif
31+
}
32+
2233
/// <summary>
2334
/// Executes the specified action in a separate thread.
2435
/// </summary>
2536
/// <param name="action">The action to execute.</param>
2637
public static void ExecuteThread(Action action)
2738
{
28-
if (action == null)
29-
throw new ArgumentNullException("action");
30-
3139
#if FEATURE_THREAD_THREADPOOL
3240
System.Threading.ThreadPool.QueueUserWorkItem(o => action());
3341
#elif FEATURE_THREAD_TAP

0 commit comments

Comments
 (0)