Thread.IsUIThread
public static class ThreadExtensions { public static bool IsUIThread(this Thread thread) { return SynchronizationContext.Current != null; } }