Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我想要启动屏幕,直到我的表单';s承包商dosn';登录后快速显示我的表单_C#_Winforms - Fatal编程技术网

C# 我想要启动屏幕,直到我的表单';s承包商dosn';登录后快速显示我的表单

C# 我想要启动屏幕,直到我的表单';s承包商dosn';登录后快速显示我的表单,c#,winforms,C#,Winforms,我的应用程序是基于硬件的,所以它在第一个表单的构造函数myform中有连接。 我想在后台加载我的表单之前显示启动屏幕。 在c语言中的应用。 启动屏幕后将显示登录。检查我的SimpleSplash实现 public sealed class SplashForm<T> : Form where T : Form { public SplashForm() { SuspendLayout(); Size = new Size(35

我的应用程序是基于硬件的,所以它在第一个表单的构造函数myform中有连接。 我想在后台加载我的表单之前显示启动屏幕。 在c语言中的应用。
启动屏幕后将显示登录。

检查我的SimpleSplash实现

public sealed class SplashForm<T> : Form
    where T : Form
{
    public SplashForm()
    {
        SuspendLayout();

        Size = new Size(350, 100);
        StartPosition = FormStartPosition.CenterScreen;
        FormBorderStyle = FormBorderStyle.None;

        var lblMessage = new Label
        {
            Location = new Point(10, 10),
            Text = "loading..."
        };

        Controls.Add(lblMessage);

        ResumeLayout(false);
        PerformLayout();

        LoadMainForm();
    }

    private async void LoadMainForm()
    {
        Form instance = null;
        await Task.Run(() =>
        {
            //--get the main form type
            var firstFormType = GetType().GenericTypeArguments.First();
            //--create the instance
            instance = Activator.CreateInstance(firstFormType) as Form;
        });

        if (instance == null)
            throw new InvalidOperationException("form initialization error");

        OnMainFormLoaded(instance);
    }

    public event EventHandler<Form> MainFormLoaded;

    private void OnMainFormLoaded(Form formInstance)
    {
        EventHandler<Form> handler = MainFormLoaded;
        if (handler != null)
            handler(this, formInstance);
    }
}
您需要对应用程序入口点进行一些调整

internal static class Program
{
    [STAThread]
    private static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        Form mainFormInstance = null;

        var splash = new SplashForm<MainForm>();
        splash.MainFormLoaded +=
            (s, e) =>
            {
                mainFormInstance = e;
                splash.Dispose();
            };

        Application.Run(splash);
        Application.Run(mainFormInstance);
    }
}
内部静态类程序
{
[状态线程]
私有静态void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
表单mainFormInstance=null;
var splash=新SplashForm();
splash.mainformload+=
(s,e)=>
{
mainFormInstance=e;
splash.Dispose();
};
应用程序。运行(飞溅);
应用程序运行(mainFormInstance);
}
}

我希望这会有帮助。

你听起来像是在请别人帮你做这件事。你应该表现出你已经付出了一些努力。我是初学者。我只是想得到一些帮助或指导。谷歌是你的朋友:tinyurl.com/nw3b9qe我想在这里我会找到一些技术上的答案。但不是bad@AkshayKhade检查我的答案。如果有帮助,请标记为答案。
internal static class Program
{
    [STAThread]
    private static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        Form mainFormInstance = null;

        var splash = new SplashForm<MainForm>();
        splash.MainFormLoaded +=
            (s, e) =>
            {
                mainFormInstance = e;
                splash.Dispose();
            };

        Application.Run(splash);
        Application.Run(mainFormInstance);
    }
}