Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ThreadUtil {
- public static int UIThreadId;
- public static void EnsureNotUIThread() {
- if ( Thread.CurrentThread.ManagedThreadId == UIThreadId ) {
- throw new InvalidOperationException("Bad thread");
- }
- }
- }
- Interlocked.Exchange(ref ThreadUtil.UIThreadID, Thread.CurrentThread.ManagedThreadId);
- public static bool IsBackground() {
- return null == SynchronizationContext.Current;
- }
Add Comment
Please, Sign In to add comment