lith 3 年之前
父节点
当前提交
dad8075bf0
共有 1 个文件被更改,包括 10 次插入2 次删除
  1. 10 2
      dotnet/Library/Vit/Vit.Core/Vit.Core/Util/Threading/Worker/TaskQueue.cs

+ 10 - 2
dotnet/Library/Vit/Vit.Core/Vit.Core/Util/Threading/Worker/TaskQueue.cs

@@ -20,12 +20,15 @@ namespace Vit.Core.Util.Threading.Worker
         /// 线程名称
         /// 线程名称
         /// </summary>
         /// </summary>
         public string threadName{ get => taskToInvokeTask.threadName; set => taskToInvokeTask.threadName = value; }
         public string threadName{ get => taskToInvokeTask.threadName; set => taskToInvokeTask.threadName = value; }
+        public bool IsRunning => taskToInvokeTask.IsRunning;
+
 
 
 
 
         #region Start Stop
         #region Start Stop
 
 
         public bool Start()
         public bool Start()
         {
         {
+            if (IsRunning) return false;
             try
             try
             {
             {
                 taskToInvokeTask.Processor = InvokeTaskInQueue;
                 taskToInvokeTask.Processor = InvokeTaskInQueue;
@@ -37,21 +40,26 @@ namespace Vit.Core.Util.Threading.Worker
             catch (Exception ex)
             catch (Exception ex)
             {
             {
                 Logger.Error(ex);
                 Logger.Error(ex);
-                return false;
             }
             }
+
+            return false;
         }
         }
 
 
-        public void Stop()
+        public bool Stop()
         {
         {
+            if (!IsRunning) return false;
             try
             try
             {
             {
                 taskToInvokeTask.Stop();
                 taskToInvokeTask.Stop();
                 Logger.Info("[" + nameof(TaskQueue) + "] Thread Stoped", taskToInvokeTask.threadName);
                 Logger.Info("[" + nameof(TaskQueue) + "] Thread Stoped", taskToInvokeTask.threadName);
+                return true;
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
                 Logger.Error(ex);
                 Logger.Error(ex);
             }
             }
+
+            return false;
         }
         }
         #endregion
         #endregion