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)