소스 검색

Added ExecuteThreadLongRunning.

Gert Driesen 8 년 전
부모
커밋
c3927660cf
1개의 변경된 파일11개의 추가작업 그리고 3개의 파일을 삭제
  1. 11 3
      src/Renci.SshNet/Abstractions/ThreadAbstraction.cs

+ 11 - 3
src/Renci.SshNet/Abstractions/ThreadAbstraction.cs

@@ -19,15 +19,23 @@ namespace Renci.SshNet.Abstractions
 #endif
         }
 
+        public static void ExecuteThreadLongRunning(Action 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();
+#endif
+        }
+
         /// <summary>
         /// Executes the specified action in a separate thread.
         /// </summary>
         /// <param name="action">The action to execute.</param>
         public static void ExecuteThread(Action action)
         {
-            if (action == null)
-                throw new ArgumentNullException("action");
-
 #if FEATURE_THREAD_THREADPOOL
             System.Threading.ThreadPool.QueueUserWorkItem(o => action());
 #elif FEATURE_THREAD_TAP