using System;
namespace Renci.SshNet.Abstractions
{
internal static class ThreadAbstraction
{
///
/// Suspends the current thread for the specified number of milliseconds.
///
/// The number of milliseconds for which the thread is suspended.
public static void Sleep(int millisecondsTimeout)
{
System.Threading.Thread.Sleep(millisecondsTimeout);
}
public static void ExecuteThreadLongRunning(Action action)
{
if (action is null)
{
throw new ArgumentNullException(nameof(action));
}
var taskCreationOptions = System.Threading.Tasks.TaskCreationOptions.LongRunning;
_ = System.Threading.Tasks.Task.Factory.StartNew(action, taskCreationOptions);
}
///
/// Executes the specified action in a separate thread.
///
/// The action to execute.
public static void ExecuteThread(Action action)
{
if (action is null)
{
throw new ArgumentNullException(nameof(action));
}
_ = System.Threading.ThreadPool.QueueUserWorkItem(o => action());
}
}
}