您的位置:首页 > 编程语言 > C#

C#中如何判断当前线程是否为主线程

2012-07-26 17:03 459 查看
C#中如何判断当前线程是否为主线程
/ Do this when you start your applicationstatic int mainThreadId;// In Main method:mainThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;// If called in the non main thread, will return false;public static bool IsMainThread{get { return System.Threading.Thread.CurrentThread.ManagedThreadId == mainThreadId; }}

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: