diff --git a/samples/Hello-Java.Base/Program.cs b/samples/Hello-Java.Base/Program.cs index ea23ff85e..7b5355e3a 100644 --- a/samples/Hello-Java.Base/Program.cs +++ b/samples/Hello-Java.Base/Program.cs @@ -38,13 +38,7 @@ public static void Main (string[] args) v => reportTiming = v != null }, { "v|verbosity:", $"Set console log verbosity to {{LEVEL}}. Default is 0.", - (int? v) => { - verbosity = v.HasValue ? v.Value : verbosity + 1; - if (verbosity > 0) { - logger = CreateConsoleLogger (); - } - } - }, + (int? v) => verbosity = v.HasValue ? v.Value : verbosity + 1 }, { "h|help", "Show this message and exit.", v => showHelp = v != null }, @@ -54,6 +48,9 @@ public static void Main (string[] args) options.WriteOptionDescriptions (Console.Out); return; } + if (verbosity > 0) { + logger = CreateConsoleLogger (); + } var builder = new JreRuntimeOptions () { JniAddNativeMethodRegistrationAttributePresent = true, JvmLibraryPath = jvmPath ?? global::Java.InteropTests.TestJVM.GetJvmLibraryPath (logger), @@ -79,6 +76,11 @@ public static void Main (string[] args) } CreateJLO (); + + GC.Collect (); + GC.Collect (); + GC.WaitForPendingFinalizers (); + GC.WaitForPendingFinalizers (); } static Action CreateConsoleLogger ()