SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
GeneralSplashScreen.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8 using System.Threading;
9 
10 namespace Sample_Environment_Control_Interface
11 {
12  public partial class GeneralSplashScreen : Form
13  {
14  private static GeneralSplashScreen _splashScreen = null;
15  private static Thread _runningThread = null;
16  private static String _message = "";
17 
18  private delegate void HideSplashScreenDelegate();
19 
21  {
23  }
24 
25  static public void ShowSplashScreen(String text)
26  {
27  _message = text;
28 
29  // Make sure it is only launched once.
30  if (_splashScreen == null)
31  {
32  _runningThread = new Thread(new ThreadStart(GeneralSplashScreen.ShowForm));
33  _runningThread.IsBackground = true;
34  _runningThread.SetApartmentState(ApartmentState.STA);
35  _runningThread.Start();
36  }
37  }
38 
39  // A private entry point for the thread.
40  static private void ShowForm()
41  {
43  _splashScreen.lblMessage.Text = _message;
44 
45  Application.Run(_splashScreen);
46  }
47 
48  // A static method to close the SplashScreen
49  static public void CloseForm()
50  {
51  if (_splashScreen != null)
52  {
53  _splashScreen.Invoke(new HideSplashScreenDelegate(HideScreen));
54  _splashScreen = null;
55  }
56  _runningThread.Abort();
57  _runningThread = null;
58  }
59 
60  static private void HideScreen()
61  {
62  _splashScreen.Visible = false;
63  }
64  }
65 }
void InitializeComponent()
Required method for Designer support - do not modify the contents of this method with the code editor...