Skip to content

Commit

Permalink
Suppress fault message box
Browse files Browse the repository at this point in the history
  • Loading branch information
Equinox- committed Feb 24, 2024
1 parent d79836a commit 2a0b09f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Meds.Watchdog/Entrypoint.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Globalization;
using System.Threading;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Meds.Dist;
using Meds.Shared;
Expand All @@ -16,8 +16,14 @@ namespace Meds.Watchdog
{
public sealed class Entrypoint
{
[DllImport("kernel32.dll")]
private static extern uint SetErrorMode(uint uMode);

public static async Task Main(string[] args)
{
// fail critical errors & no fault error box
SetErrorMode(3);

var culture = CultureInfo.GetCultureInfo("en-US");
CultureInfo.CurrentUICulture = culture;
CultureInfo.CurrentCulture = culture;
Expand Down Expand Up @@ -71,6 +77,7 @@ await Console.Error.WriteLineAsync(
{
await host.RunAsync();
}

// Force exit in case a background thread is frozen.
Environment.Exit(0);
}
Expand Down
8 changes: 8 additions & 0 deletions Meds.Wrapper/Entrypoint.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Meds.Shared;
using Meds.Wrapper.Shim;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -17,8 +19,14 @@ public static class Entrypoint

public static ILogger LoggerFor(Type type) => Instance?.Services.GetRequiredService<ILoggerFactory>().CreateLogger(type);

[DllImport("kernel32.dll")]
private static extern uint SetErrorMode(uint uMode);

public static void Main(string[] args)
{
// fail critical errors & no fault error box
SetErrorMode(3);

var culture = CultureInfo.GetCultureInfo("en-US");
CultureInfo.CurrentUICulture = culture;
CultureInfo.CurrentCulture = culture;
Expand Down

0 comments on commit 2a0b09f

Please sign in to comment.