From 968fd667a81ba3d47dfec132653262a7ec2fb7a5 Mon Sep 17 00:00:00 2001 From: cmurialdo Date: Wed, 23 Nov 2022 12:50:49 -0300 Subject: [PATCH] Store the MainContext of command line executions. Only main context must wait for unfinished submit threads. It will be improved making main procedures extend GXMainProcedure. --- 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 33568f6bf..9fd05800c 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 3c9153a4f..f45d80700 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)