风雨漂泊

 

webbrowser的线程访问问题

 

第一点:[STAThread]  

        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LoginFrm());
        }

 

第二点:thread.SetApartmentState(ApartmentState.STA);     ApartmentState.STA:将创建并进入一个单线程单元

            Thread thread = new Thread(Login);
            thread.SetApartmentState(ApartmentState.STA);  
            thread.Start();

  

posted on 2013-05-24 17:07  lispo  阅读(172)  评论(0)    收藏  举报

导航