Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Verify UnmanagedCallersOnlyAttribute for callback handlers #857

@badcel

Description

@badcel

Callback Handlers need to provide a native function which can be called from C.

The UnmanagedCallersOnlyAttribute allows to call a function directly from native code.

Verify if it is possible to improve the handlers. For this to work we need to pass data around which can be done via the user_data parameters of callbacks:

  1. Pin data via var data = GCHandle.Alloc(action);
  2. Pass data via the user_data parameter: GCHandle.ToIntPtr(data)
  3. Restore data from user_data parameter: GCHandle.FromIntPtr(data).Target
  4. Free data via: GCHandle.FromIntPtr(data).Free();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions