using VoiceCat.App.Forms; namespace VoiceCat.App; internal static class Program { [STAThread] private static int Main(string[] args) { // Surface exceptions that WinForms' default message-loop handling would otherwise // swallow silently (or crash with no visible cause). Application.ThreadException += (_, e) => Console.Error.WriteLine($"[UNHANDLED ThreadException] {e.Exception}"); AppDomain.CurrentDomain.UnhandledException += (_, e) => Console.Error.WriteLine($"[UNHANDLED AppDomain exception] {e.ExceptionObject}"); ApplicationConfiguration.Initialize(); if (args.Contains("--smoke-test")) { try { using var client = new VoiceCat.Interop.VoiceCatClient("Smoke", "test"); using var form = new MainForm(client, 0, "Smoke", "Managed core"); form.CreateControl(); if (form.Controls.Count == 0 || string.IsNullOrEmpty(form.Text)) return 1; client.PumpEvents(); if (args.Contains("--audio")) { var backend = new Audio.WasapiAudioBackend(); using var playback = backend.OpenPlayback(); int samples = 0; using var capture = backend.OpenCapture(null, false, (pcm, _) => Interlocked.Add(ref samples, pcm.Length)); short[] silence = new short[1920]; for (int i = 0; i < 150; i++) { playback.Write(silence); Thread.Sleep(20); } if (samples == 0) return 2; } return 0; } catch { return 1; } } using var connectDialog = new ConnectDialog(); var result = connectDialog.ShowDialog(); if (result != DialogResult.OK || connectDialog.ConnectedClient is null) return 0; Application.Run(new MainForm(connectDialog.ConnectedClient, connectDialog.SelfUserId, connectDialog.Nickname, connectDialog.ServerName)); return 0; } }