Skip to content

Commit 5d173c8

Browse files
committed
Streamline ThreadAbstraction to remove ambiguity wrt different build targets
1 parent cd69534 commit 5d173c8

File tree

1 file changed

+0
-17
lines changed

1 file changed

+0
-17
lines changed

src/Renci.SshNet/Abstractions/ThreadAbstraction.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,17 @@ internal static class ThreadAbstraction
1010
/// <param name="millisecondsTimeout">The number of milliseconds for which the thread is suspended.</param>
1111
public static void Sleep(int millisecondsTimeout)
1212
{
13-
#if FEATURE_THREAD_SLEEP
1413
System.Threading.Thread.Sleep(millisecondsTimeout);
15-
#elif FEATURE_THREAD_TAP
16-
System.Threading.Tasks.Task.Delay(millisecondsTimeout).GetAwaiter().GetResult();
17-
#else
18-
#error Suspend of the current thread is not implemented.
19-
#endif
2014
}
2115

2216
public static void ExecuteThreadLongRunning(Action action)
2317
{
2418
if (action == null)
2519
throw new ArgumentNullException("action");
26-
#if FEATURE_THREAD_TAP
27-
var taskCreationOptions = System.Threading.Tasks.TaskCreationOptions.LongRunning;
28-
System.Threading.Tasks.Task.Factory.StartNew(action, taskCreationOptions);
29-
#else
3020
new System.Threading.Thread(() => action())
3121
{
3222
IsBackground = true
3323
}.Start();
34-
#endif
3524
}
3625

3726
/// <summary>
@@ -40,16 +29,10 @@ public static void ExecuteThreadLongRunning(Action action)
4029
/// <param name="action">The action to execute.</param>
4130
public static void ExecuteThread(Action action)
4231
{
43-
#if FEATURE_THREAD_THREADPOOL
4432
if (action == null)
4533
throw new ArgumentNullException("action");
4634

4735
System.Threading.ThreadPool.QueueUserWorkItem(o => action());
48-
#elif FEATURE_THREAD_TAP
49-
System.Threading.Tasks.Task.Run(action);
50-
#else
51-
#error Execution of action in a separate thread is not implemented.
52-
#endif
5336
}
5437
}
5538
}

0 commit comments

Comments
 (0)