asp.net WinForm version upgrade Flash screen optimization process sharing

Source: Internet
Author: User

The most recent version of the WinForm application was a release upgrade, the test found that when no new version of the upgrade interface will flash over (splash screen), the user experience is not good, so how to solve the problem.

The main code for the upgrade is as follows:

The code is as follows Copy Code

Using System;
Using System.Windows.Forms;

Namespace WindowsFormsApplication1
{
public partial class Form1:form
{
Public Form1 ()
{
InitializeComponent ();
}

private void Form1_Load (object sender, EventArgs e)
{
1. Test version
BOOL Havnewver = Checknewver ();
2. Program upgrades
if (Havnewver && MessageBox.Show ("Found new version: 3.0, update?") "," Update ", Messageboxbuttons.yesno, messageboxicon.information) = = Dialogresult.yes)
{
Todo
}
3. Exit Application
Application.exit ();
}

<summary>
Detecting a new version
</summary>
<returns></returns>
private bool Checknewver ()
{
return false;
}
}
}

The beginning of the idea is to hide the form first, and so on to confirm the upgrade and then display the form, modify, test can solve the splash screen problem [1]:

  code is as follows copy code

Private void Form1_Load (object sender, EventArgs e)
{
   //1. Detection version
    bool Havnewver = Checknewver ();
   //2. Program Upgrades
    if (havnewver && MessageBox.Show ("Discover new version: 3.0, update? "," Update ", Messageboxbuttons.yesno, messageboxicon.information) = = Dialogresult.yes)
    {
        //Display form (first set form properties in designer Windowstate=minimized,showintaskbar=false)
         this. WindowState = Formwindowstate.normal;
        this. ShowInTaskbar = true;

       //todo
   }
   //3. Exit Application
    Application.exit ();
}

Is there any other way out? After analysis, the detection version and FROM1 form does not matter, if you can detect the version first, confirm the upgrade and then initialize the display Form1 form logically more appropriate, will also be able to solve the splash screen problem, can this be achieved? You can move the detection process to the application entry function, and the modified Program.cs is as follows:

The code is as follows Copy Code

Using System;
Using System.Collections.Generic;
Using System.Windows.Forms;

Namespace WindowsFormsApplication1
{
    static class program
    {
& nbsp;      ///<summary>
       /// The main entry point for the application.
       ///</summary>
         [STAThread]
        static void Main (params string[] args)
         {
            Application.enablevisualstyles ();
            Application.setcompatibletextrenderingdefault (FALSE);
           //application.run (New Form1 ());

           //1. Detection version
             bool Havnewver = Checknewver ();
           //2. Program Upgrades
             if (havnewver && MessageBox.Show ("Found new version: 3.0, update?") "," Update ", Messageboxbuttons.yesno, messageboxicon.information) = = Dialogresult.yes)
             {
                 Application.Run (New Form1 ());
           }
       }

<summary>
Detecting a new version
</summary>
<returns></returns>
static bool Checknewver ()
{
return false;
}
}
}

One of the advantages of this change is that it solves the problem of passing the old version parameter of the application (passed in from the main function parameter).

Supplementary notes

[1]. Set the form property This.visible = False in Form1_Load, or call method this. Hide (); Cannot hide form;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.