如何在不飞溅的情况下停止表格5秒钟 [英] how do stop form for 5 second without splash

查看:58
本文介绍了如何在不飞溅的情况下停止表格5秒钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我有一个形式,如飞溅(我不想飞溅)

我希望此表单显示5秒钟,然后在下面的语句中执行

然后基于结果,显示两种形式之一如果不存在连接,则关闭应用程序

hi all

i have a form like splash (i dont want splash)

i want this form show for 5 second and then execute below statement

then Based on result , show one of two forms or if connection not exists close application

try
            {
                    SqlConnection MySqlConnection = new  SqlConnection(ConnectionMain.strconnection);
                    SqlCommand MySqlCommand = MySqlConnection.CreateCommand();
                    MySqlCommand.CommandText = "FormSelector";
                    MySqlCommand.CommandType = CommandType.StoredProcedure;
                
                    SqlParameter returnValue = new SqlParameter("returnVal", SqlDbType.Int);
                    returnValue.Direction = ParameterDirection.ReturnValue;
                    MySqlCommand.Parameters.Add(returnValue);

                    if (MySqlConnection.State != ConnectionState.Open)
                    {
                        MySqlConnection.Open();
                    }

                    MySqlCommand.ExecuteNonQuery();

                    int result = Convert.ToInt32(returnValue.Value);


                    if (MySqlConnection.State != ConnectionState.Closed)
                    {
                        MySqlConnection.Close();
                    }
                    if (result == 1)
                    {
                        this.Hide();
                        login frm_login = new login();
                        frm_login.ShowDialog();
                        this.Close();
                    }
                    else if (result == 2)
                    {
                        this.Hide();
                        main frm_main = new main();
                        frm_main.ShowDialog();
                        this.Close();
                    }
                }
            catch (Exception error)
            {
                DialogResult dr = MessageBoxFarsi.Show("Connection Error");
                Application.Exit();
            }



我怎么办?

请帮助我

非常感谢



how do i it ?

Please Help Me

Thanks A Lot

推荐答案

如果您只想让线程休眠一段时间,则可以使用例如:
If you just want the thread to sleep for a while, then you can use for example:
System.Threading.Thread.Sleep(50000);


这篇关于如何在不飞溅的情况下停止表格5秒钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆