소스 검색

PsQueue: Fix StartFail test

Dalibor Votruba 1 년 전
부모
커밋
8e7b8c900e
2개의 변경된 파일20개의 추가작업 그리고 20개의 파일을 삭제
  1. 0 5
      qdr.fnd.core.pqueue/Exceptions/PsProcessProviderException.cs
  2. 20 15
      qdr.fnd.core.pqueue/Process/PsProcessProviderBase.cs

+ 0 - 5
qdr.fnd.core.pqueue/Exceptions/PsProcessProviderException.cs

@@ -1,10 +1,5 @@
 using Quadarax.Foundation.Core.Attributes;
 using Quadarax.Foundation.Core.Exceptions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace qdr.fnd.core.pqueue.Exceptions
 {

+ 20 - 15
qdr.fnd.core.pqueue/Process/PsProcessProviderBase.cs

@@ -70,7 +70,7 @@ namespace qdr.fnd.core.pqueue.Process
             OnValidate();
         }
         /// <inheritdoc />
-        public async void Start()
+        public void Start()
         {
             if (IsRunning)
                 throw new PsProcessProviderException(PsProcessProviderException.ErrorCodes.ProcessProviderIsRunning, GetType().Name, ItemId);
@@ -81,24 +81,29 @@ namespace qdr.fnd.core.pqueue.Process
             StartedTimestamp = DateTime.Now;
             var timeout = GetArgumentValue<TimeSpan>(CS_ARG_PROCESS_TIMEOUT);
 
-            try
+
+            Task.Run(async () =>
             {
-                await TimeoutUtils.ExecuteWithTimeoutAsync(async () =>
+
+                try
                 {
+                    await TimeoutUtils.ExecuteWithTimeoutAsync(async () =>
+                    {
 
-                    await OnProcess().ContinueWith(task =>
+                        await OnProcess().ContinueWith(task =>
+                        {
+                            ProcessDoneOk("Succesfuly done.");
+                        });
+                    }, timeout);
+                }
+                catch (Exception e)
+                {
+                    await OnProcessError(e).ContinueWith(task =>
                     {
-                        ProcessDoneOk("Succesfuly done.");
+                        ProcessDoneFailed(e.Message, e);
                     });
-                }, timeout);
-            }
-            catch (Exception e)
-            {
-                await OnProcessError(e).ContinueWith(task =>
-                {
-                    ProcessDoneFailed(e.Message, e);
-                });
-            }
+                }
+            });
         }
 
         /// <inheritdoc />
@@ -107,7 +112,7 @@ namespace qdr.fnd.core.pqueue.Process
             if (!IsRunning)
                 throw new PsProcessProviderException(PsProcessProviderException.ErrorCodes.ProcessProviderNotRunning, GetType().Name, ItemId);
 
-            _cancelationToken?.Cancel();            
+            _cancelationToken?.Cancel();
             ProcessDoneFailed("Process was forced stopped.");
             Log.Log(LogSeverityEnum.Info, $"Provider for ItemId='{ItemId}' was forced stopped.");
         }