Skip to content

CancelKeyPress event handler should be allocated before TraceEventSession resource acquisition #44

@jzabroski

Description

@jzabroski

https://github.com/Microsoft/dotnet-samples/blob/6f2414148e33740c29116138e8bcef28364fafa8/Microsoft.Diagnostics.Tracing/TraceEvent/TraceEvent/10_SimpleEventSourceMonitor.cs#L95

There is a small chance that System.Environment.Exit can be called prior to the event handler being wired up. In this scenario, despite the huge amount of gracious and fantastic warnings about the importance of wiring up this event, the EventTraceSession will hang around after the program has exited. (Thank you to whoever spent the time to write up this fantastic example, by the way - it definitely pointed me in the right direction.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions