关于C#登陆窗体的问题!
我要登陆后弹出其他窗体,登陆窗体自动关闭不占用线程,该怎么实现呢?
程序代码:using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace LandLoadExample
{
static class Program
{
static FrmMain mainForm;
static FrmLand landForm;
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
mainForm = new FrmMain();
mainForm.VisibleChanged += new EventHandler(mainForm_VisibleChanged);
mainForm.Visible = false;
landForm = new FrmLand();
landForm.LogSuccess += new EventHandler(landForm_LogSuccess);
Application.Run(mainForm);
}
static void mainForm_VisibleChanged(object sender, EventArgs e)
{
landForm.ShowDialog();
}
static void landForm_LogSuccess(object sender, EventArgs e)
{
mainForm.Visible = true;
landForm.Close();
}
}
}
程序代码:using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace LandLoadExample
{
public partial class FrmLand : Form
{
public FrmLand()
{
InitializeComponent();
}
/// <summary>
/// 自定义的LogSuccess事件
/// </summary>
public event EventHandler LogSuccess;
/// <summary>
/// 单击OK按钮事件处理
/// </summary>
/// <param name="sender">窗体</param>
/// <param name="e">未使用</param>
private void btnOk_Click(object sender, EventArgs e)
{
if (this.LogSuccess != null)
{
this.LogSuccess(this, new EventArgs());
}
}
}
}