Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is an example of a splashscreen - I have used in one of my projects - that uses multithreading: </p> <pre><code>namespace WindowsForm1 { public enum SplashTypeOfMessage { Success, Warning, Error } public partial class SplashForm : Form { static SplashForm _splashForm = null; static Thread _splashThread = null; public static object locker = new object(); public static bool WaitPlease = true; private SplashForm() { InitializeComponent(); lblLoading.Text = "Please wait Loading"; } public static void ShowSplashScreen() { if (_splashForm != null) return; _splashThread = new Thread(new ThreadStart(SplashForm.ShowSplash)); _splashThread.IsBackground = true; _splashThread.SetApartmentState(ApartmentState.STA) ; _splashThread.Start(); } public static void ShowSplash() { if (_splashForm==null) { _splashForm = new SplashForm(); _splashForm.blueLoaderBar1.StartAnimation(); } _splashForm.TopMost = true; _splashForm.Show(); lock (SplashForm.locker) { WaitPlease = false; } Application.Run(_splashForm); } delegate void CloseSplashHandler(SplashTypeOfMessage typeOfMessage, string message,bool itWasRinvoked); public static void CloseSplash(SplashTypeOfMessage typeOfMessage,string message,bool itWasrinvoked) { CloseSplashHandler closeSpalshHandler = new CloseSplashHandler(CloseSplash); bool launched=false; while (!launched &amp;&amp; !itWasrinvoked) { lock (SplashForm.locker) { if (!SplashForm.WaitPlease) { launched = true; } } } if (_splashForm!=null &amp;&amp; _splashThread!=null ) { if (_splashForm.InvokeRequired) { _splashForm.Invoke(closeSpalshHandler,new object[] {typeOfMessage,message,true}); } else { switch (typeOfMessage) { case SplashTypeOfMessage.Warning: break; case SplashTypeOfMessage.Error: MessageBox.Show("Error"); break; default: break; } _splashForm.Close(); _splashThread = null; } } } } } </code></pre> <p>Here is how you can call it: </p> <pre><code>SplashForm.ShowSplashScreen(); </code></pre> <p>This is how you can close the splash screen: </p> <pre><code>SplashForm.CloseSplash(typeOfMessage ,string.Empty,false); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload