C# 飞溅屏幕显示在应用程序的中间

C# 飞溅屏幕显示在应用程序的中间,c#,winforms,C#,Winforms,在ReportViewer控件中,我有一个显示为树层次结构的报表名称列表。当用户单击报表名称时,将加载一个输入表单,用户输入一些值并按OK。此时,启动屏幕应该在后端进程发生时加载(连接到DB、检索值等)。在Reportviewer编辑器中加载报告后,splashscreen应关闭 到目前为止,我能够显示启动屏幕,但它在那一点上卡住了,实际的报告不会加载,启动屏幕永远保持打开状态 是否有可能在应用程序中间使用飞溅屏幕,而不是在应用程序启动时使用?如果是,如何继续加载报告 static class

在ReportViewer控件中,我有一个显示为树层次结构的报表名称列表。当用户单击报表名称时,将加载一个输入表单,用户输入一些值并按OK。此时,启动屏幕应该在后端进程发生时加载(连接到DB、检索值等)。在Reportviewer编辑器中加载报告后,splashscreen应关闭

到目前为止,我能够显示启动屏幕,但它在那一点上卡住了,实际的报告不会加载,启动屏幕永远保持打开状态

是否有可能在应用程序中间使用飞溅屏幕,而不是在应用程序启动时使用?如果是,如何继续加载报告

static class Program
{
    [STAThread]
    static void Main(string[] args)

    {

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new SnapPlusReports());

        //new SplashScreenApp().Run(args);
    }
}

public class SplashScreenApp : WindowsFormsApplicationBase
{
    private static SplashScreenApp _application;

    public static void Run(Form form)
    {
        _application = new SplashScreenApp { MainForm = form };
        _application.Run(Environment.GetCommandLineArgs());
    }

    protected override void OnCreateSplashScreen()
    {
        this.SplashScreen = new ShowProgress();
        base.OnCreateSplashScreen();
    }

}

我以前通过在运行时使用代码动态生成一个新表单来实现这一点。确保您设置了所有选项,尤其是FormBorderStyle为none,或类似的设置,以便用户无法关闭它。然后简单地操作表单上显示的标签,并在流程完成后最终关闭它。 这样您就不必担心线程问题,一个很好的副作用是初始表单将不可单击

例如,我有一个在运行时弹出的about表单(尽管我没有对其进行任何更改,但其想法是:

AboutForm aboutForm = new AboutForm();
aboutForm.StartPosition = FormStartPosition.CenterParent;
Label lblAbout = new Label();
Version applicationVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
lblAbout.Text = applicationVersion.ToString();
lblAbout.Location = new Point(145,104);
aboutForm.Controls.Add(lblAbout);
aboutForm.ShowDialog();
这显示了当前程序的版本号等。表单上已经存在其他标签(我首先以可视化方式创建了它,然后调用了它的一个实例)


希望这有帮助!

…如果您在给定时间只需要内存中的应用程序的一个副本,请捕获其他实例并优雅地退出

static void Main()
{
    Application.EnableVisualStyles();
    bool exclusive;
    System.Threading.Mutex appMutex = new System.Threading.Mutex(true, "MY_APP", out exclusive);
    if (!exclusive)
    {
         MessageBox.Show("Another instance of xxxx xxxBuilder is already running.","MY_APP",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Exclamation );
                    return;
    }
    Application.SetCompatibleTextRenderingDefault(false);
    xxxWindowsApplication.InitializeApplication();
    Application.Run(new frmMenuBuilderMain());
                GC.KeepAlive(appMutex);
            }
在主窗体加载中,您可以执行以下操作:

private void frmMenuBuilderMain_Load(object sender, EventArgs e)
{   

     //Show Splash with timeout Here--
     if(!SystemLogin.PerformLogin())             
     {
         this.Close();
         return;
     }
     tmrLoad.Enabled = true;

}

您是否尝试过使用
BeginInvoke()
要在单独的线程上运行它吗?另外,您没有将其显示为模态,对吗?请为特定的解决方案发布一些代码…您确定您的工作安排在后台线程而不是UI线程本身上吗?@allen-我正在尝试使用Visual Basic assembly进行此操作。这里有一个链接-@PinnyM-添加了一些代码。它在k应用程序启动。但这不是我想要的。我希望加载进度条,然后在reportviewer编辑器加载报告时它应该关闭。我很好奇你是否找到了解决此问题的方法,以及你使用了什么。这是否有进度条?或者只是带有标签的表单?你可以用标签的方式添加进度条dded.i.e.ProgressBar pgBar=new ProgressBar();。然后您可以使用与标签相同的方式编辑其位置、属性等。