首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

调用线程务必为 STA,因为许多 UI 组件都需要

2012-12-30 
调用线程必须为 STA,因为许多 UI 组件都需要class Mainclass{[STAThread]static void Main(){Application

调用线程必须为 STA,因为许多 UI 组件都需要

class Mainclass    {        [STAThread]        static void Main()        {            Application app = new Application();            MainWindow win = new MainWindow();            app.Startup += new StartupEventHandler(app_Startup);            app.Run();        }        static void app_Startup(object sender,StartupEventArgs e)        {            MessageBox.Show("fdf");        }    }

需要在 Main() 方法前添加 [STAThread]

热点排行