How to call mono_threads_request_thread_dump() from C#?

Viewed 98
1 Answers

Use a DllImport of __Internal to call native methods within the host.

Example:

[DllImport("__Internal")]
public static extern void mono_threads_request_thread_dump();

public static void Main(string[] args)
{
    mono_threads_request_thread_dump();
    Console.WriteLine("Hello World!");
}

Output:

Full thread dump:

"<unnamed thread>"  at <unknown> <0xffffffff>
  at Console_ThreadDump.MainClass.Main (string[]) [0x00007] in /Volumes/Code/code/Projects/Console_ThreadDump/Console_ThreadDump/Program.cs:14
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) [0x00051] in <e3877a65d90742cebc8141de4055f006>:0

"Debugger agent"
"Finalizer"Hello World!

Press any key to continue...
Related