Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Main Thread
Thread uiThread;
uiThread = Thread.CurrentThread; //Ensure this is called during a Main/UI thread call
void WhatThreadAmI([CallerMemberName] string method = "", [CallerLineNumber] int line = 0)
{
Console.WriteLine("=========================");
Console.WriteLine("=========================");
Console.WriteLine("=========================");
Console.WriteLine($"{method} - {line}" {IsMainThread}");
Console.WriteLine("=========================");
Console.WriteLine("=========================");
Console.WriteLine("=========================");
}
public bool IsMainThread => uiThread == Thread.Current;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.