简体   繁体   English

C# 启动画面不工作

[英]C# Splash screen not working

I've been stuck here for a few hours looking up code for hours and making batches of my own.我被困在这里几个小时,花了几个小时查找代码并自己制作批次。 One of the code ex I got from here gave me a instant svHost error.我从这里得到的代码 ex 给了我一个即时的 svHost 错误。

Now my splash screen is my HWID / Serial check, if valid it opens the main form if not it closes the app completely.. But the issue is I've tried some way's with splash.show();现在我的启动画面是我的 HWID / 串行检查,如果有效,它会打开主窗体,如果不是,它会完全关闭应用程序。但问题是我已经尝试了一些方法 splash.show(); on the main form but it just freezes and goes all stupid for a few minutes, another thing most of the methods use timers I just need it so when HWID check is valid I can start the main form, I've tried application.Run(new mainForm());在主窗体上,但它只是冻结并在几分钟内变得愚蠢,另一件事是大多数方法使用计时器我只需要它所以当 HWID 检查有效时我可以启动主窗体,我已经尝试过 application.Run(新的主窗体()); if the HWID was correct then changed the program.cs file around but still no luck, I really need the help.如果 HWID 正确,则更改 program.cs 文件但仍然没有运气,我真的需要帮助。 It would be wonderful, thank's.太好了,谢谢。

I've used splash screen animation while I'm connecting to socket.我在连接到套接字时使用了启动画面 animation。 I've used backgroundworker for it.我为此使用了backgroundworker

Here's my code:这是我的代码:

Main Form主窗体

LoadingScreen frmLoadingScreen = new LoadingScreen();
.....
bkwNetworkConnector.RunWorkerAsync();

frmLoadingScreen.ShowDialog();

 /***********************************************************************************************************************/
        private void bkwNetworkConnector_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                hostSocket = new TcpClient();
                hostSocket.Connect(strIp, intPort);
            }
            catch (Exception exp)
            {

            }
        }

        private void bkwNetworkConnector_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            frmLoadingScreen.Close();

        }

LoadingScreen Form:加载屏幕表单:

with imagebox control.带有imagebox控件。 Load GIF image in it.在其中加载 GIF 图像。

private void LoadingScreen_Load(object sender, EventArgs e)
        {
            pbAnimationBox.Image = Properties.Resources.LoadingAnimation; // win 8 animation
        }

I'm using LoadingScreen Form as splash screen.我正在使用 LoadingScreen Form 作为初始屏幕。

Hope this will hep you....希望这会帮助你......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM