Windows应用程序在点击按钮时大部分时间都会冻结。

问题描述 投票:0回答:1

我正在开发一个windows应用程序,该程序在点击主页上的按钮事件时,大部分时间都会冻结。请找到下面的代码供您参考。谅谅

using System;
using System.Windows.Forms;

namespace FileMigrationAgen
{
    public partial class HomePage : Form
    {
        public HomePage()
        {
            InitializeComponent();
        }

        private void tableLayoutPanel4_Paint(object sender, PaintEventArgs e)
        {

        }

        private async void button1_Click(object sender, EventArgs e)
        {
            SharepointMigration sharepointMigration = new SharepointMigration();
            sharepointMigration.Show();
            this.Hide();
            }

        private async void button2_Click(object sender, EventArgs e)
        {
            OneDriveMigration oneDriveMigration = new OneDriveMigration();
            oneDriveMigration.Show();
            this.Hide();            
        }


        private void HomePage_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }
    }
}

forms winforms
1个回答
0
投票

我不建议用你的方式来执行导航--隐藏父表单等。

请看一下 这条 它有一个使用静态类来执行导航和跟踪导航栈的例子。

© www.soinside.com 2019 - 2024. All rights reserved.