From 39a13e0c6e629c794fad4b76b0fd7fe2e6f35341 Mon Sep 17 00:00:00 2001 From: claudiamurialdo <33756655+claudiamurialdo@users.noreply.github.com> Date: Mon, 28 Nov 2022 16:35:56 -0300 Subject: [PATCH] Store the MainContext of command line executions. Only main context must wait for unfinished submit threads. (#722) It will be improved making main procedures extend GXMainProcedure. (cherry picked from commit f9ec62c4a63183e3b148396eeb921f9edf666ce4) --- dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs | 6 ++++++ dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs b/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs index f5ab562f3..91cb9c9f3 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs @@ -307,6 +307,10 @@ public override void Abort() } } #endif + internal class GxApplication + { + internal static GxContext MainContext { get; set; } + } [Serializable] public class GxContext : IGxContext { @@ -448,6 +452,8 @@ public GxContext() setContext(this); httpContextVars = new GxHttpContextVars(); GXLogging.Debug(log, "GxContext.Ctr Default handle:", () => _handle.ToString()); + if (GxApplication.MainContext == null && !(IsHttpContext || GxContext.IsRestService)) + GxApplication.MainContext = this; } public GxContext(int handle, string location) { diff --git a/dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs b/dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs index 6168de075..8566d8d32 100644 --- a/dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs +++ b/dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs @@ -46,7 +46,6 @@ public abstract class GXProcedure: GXBaseObject private DateTime beginExecute; private ProcedureInfo pInfo; #endif - public GXProcedure() { #if !NETCORE @@ -56,10 +55,10 @@ public GXProcedure() beginExecute = DateTime.Now; pInfo = ProceduresInfo.addProcedureInfo(name); pInfo.incCount(); - } #endif } + public bool DisconnectAtCleanup { get{ return disconnectUserAtCleanup;} @@ -91,7 +90,7 @@ protected void exitApplication() } private void exitApplication(bool flushBatchCursor) { - if (!(GxContext.IsHttpContext || GxContext.IsRestService) && IsMain && !(context as GxContext).IsSubmited) + if (!(GxContext.IsHttpContext || GxContext.IsRestService) && IsMain && GxApplication.MainContext==context) ThreadUtil.WaitForEnd(); if (flushBatchCursor)