Skip to content

Instantly share code, notes, and snippets.

@JonDouglas
Created May 4, 2016 17:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonDouglas/0d83603460e28deccc5ad4991913a6bd to your computer and use it in GitHub Desktop.
Save JonDouglas/0d83603460e28deccc5ad4991913a6bd to your computer and use it in GitHub Desktop.
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