Skip to content

Unmanaged-managed call transition callback #45118

@NN---

Description

@NN---

Background and Motivation

Proposed API

A callback when a flow comes back from unmanaged into managed code.

Usage Examples

BackToManaged += (sender, args) => {
  Console.WriteLine($"Back from {args.StackTrace}");
};

BackToManagedInCurrentThread += (sender, args) => {
  Console.WriteLine($"Back from {args.StackTrace}");
};

The use case is working with COM objects where there are many entry points into managed code.
It allows to implement behavior similar to Thread.Abort but in a safe and controlled way.

Alternative Designs

Probably can be done with ComWrappers or Source Generators.

Risks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions