Run multiple UI Threads

后端 未结 4 419
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 11:10

Skip to the bottom for the question; this is just some extra info

I am using a component (GeckoFX) to render some websites, well fine, yet it can only be us

4条回答
  •  一生所求
    2020-11-28 11:35

    I don't think that what you ask is really what you want but creating a message pump per thread is easy, you just have to call Application.Run once per thread.

    static class Program
    {
        /// 
        /// The main entry point for the application.
        /// 
        [STAThread]
        static void Main()
        {
            Thread t1 = new Thread(Main_);
            Thread t2 = new Thread(Main_);
    
            t1.Start();
            t2.Start();
    
            t1.Join();
            t2.Join();
        }
    
        static void Main_()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
    

提交回复
热议问题