static async Task Main(string[] args) { // No SDK is active: Callback should not be invoked! SentrySdk.WithClientAndScope((client, scope) => { // Create heavy event stuff var evt = new SentryEvent("Don't run me"); return(client.CaptureEvent(evt, scope)); }); // Again, as the SDK is not enabled, callback is never invoked. SentrySdk.ConfigureScope(scope => scope.AddTag(SuperHeavyMethod())); string SuperHeavyMethod() => throw new InvalidOperationException("Don't call me!"); // Program.Main should be: SentrySdk.Init(o => { // Some options o.CompressPayload = false; o.ShutdownTimeout = TimeSpan.FromSeconds(5); }); try { await App(); } catch (Exception exception) { var id = SentrySdk.CaptureException(exception); Console.WriteLine("Id: " + id); id = await SentrySdk.CaptureExceptionAsync(exception); Console.WriteLine("Id: " + id); } finally { SentrySdk.CloseAndFlush(); } // SDK can be reinitialized SentrySdk.Init(); // A second call will throw away the previous one and get a new one SentrySdk.Init(); try { throw null; } catch (Exception exception) { var id = SentrySdk.CaptureException(exception); Console.WriteLine("Id: " + id); } finally { SentrySdk.CloseAndFlush(); } // Finally, Closing a disabled SDK is a no-op SentrySdk.CloseAndFlush(); // Proposed API await ProposedApi(); }