我有一個C#應用程序,當我在加載主窗口之前使用啓動畫面時,遇到多線程/背景工作時遇到麻煩。啓動畫面+主窗口
我的代碼看起來是這樣的:
[STAThread]
private static void Main()
{
.. do some stuff
ShowSplash(); // where i show a splash screen and load some stuff
...
由於ShowSplash
最後一步,我做了以下內容:
new MyCabApplication<MyMainWorkItem, MDIParentForm>().Run(); -- where i load the form through cab.
的問題是,當我這樣做,我得到下面的異常:
在單個線程上啓動第二個消息循環不是有效的操作。使用Form.ShowDialog代替
任何想法我能做些什麼?
這裏是我的showsplash功能:
private static DialogResult ShowSplash(AutoResetEvent controller)
{
// create and register splash screen
splashScreen = new PointSplashScreen();
Application.Run(splashScreen);
return DialogResult.OK;
}
在示例中包含線程和後臺工作者代碼。 – 2010-11-03 21:34:01
按照異常消息中的建議。 – 2010-11-03 21:36:53
由於顯示啓動畫面時出現問題,因此應該發佈'ShowSplash()'的實現,以便我們可以更好地瞭解它如何最終啓動第二個消息循環。 – 2010-11-03 21:36:54