Startup Class
1: Imports System.Threading
2: Imports System.Data.SqlClient
3:
4: Public Class c_startup
5:
6: Public Event init_msg(ByVal msg As String)
7: Public Event stopthread(ByVal close As Boolean)
8:
9: Public Shared Sub Main()
10: Dim splash As New F_welcome
11: Dim log As New f_LOGIN
12: Dim win_main As New F_Main
13:
14: Application.EnableVisualStyles()
15:
16: splash.ShowDialog(win_main)
17: win_main.Show()
18: If log.ShowDialog(win_main) = DialogResult.Cancel Then
19: Application.Exit()
20: Else
21: win_main.Invalidate()
22: Application.Run(win_main)
23: End If
24: End Sub
25:
26:
27: Public Sub init()
28: 'inisialisasi
29: init_komponen()
30: init_koneksi()
31: init_akhir()
32:
33: RaiseEvent stopthread(True)
34: End Sub
35:
36: Private Sub init_komponen()
37: Dim i, x As Int16
38: Dim str As String
39: For i = 0 To 2
40: str = "Inisialisasi Komponen "
41: For x = 0 To 2
42: 'simulasi waiting dot
43: str = str.Insert(str.Length, ". ")
44: RaiseEvent init_msg(str)
45: Thread.Sleep(250)
46: Next
47: Next
48:
49: Thread.Sleep(250)
50:
51: RaiseEvent init_msg("Inisialisasi Komponen ... OK")
52: 'simulasi waktu tunggu
53: Thread.Sleep(2000)
54:
55: End Sub
56:
57: Private Sub init_koneksi()
58: Dim c As New c_koneksi
59:
60: Dim i, x, indc As Int16
61: Dim str As String
62: For i = 0 To 2
63: str = "Inisialisasi Koneksi Database "
64: For x = 0 To 2
65: 'simulasi waiting dot
66: str = str.Insert(str.Length, ". ")
67: RaiseEvent init_msg(str)
68: Thread.Sleep(300)
69: Next
70: Next
71:
72: c.get_conn(indc)
73: If indc = 0 Then
74: RaiseEvent init_msg("Inisialisasi Koneksi Database ... OK")
75: 'simulasi waktu tunggu
76: Thread.Sleep(1000)
77: Else
78: RaiseEvent init_msg("Inisialisasi Koneksi Database . . . GAGAL")
79: 'simulasi waktu tunggu
80: Thread.Sleep(1000)
81: End If
82: End Sub
83:
84: Private Sub init_akhir()
85: Dim c As New c_koneksi
86:
87: Dim i, x, indc As Int16
88: Dim str As String
89: For i = 0 To 2
90: str = "Please Wait "
91: For x = 0 To 2
92: 'simulasi waiting dot
93: str = str.Insert(str.Length, ". ")
94: RaiseEvent init_msg(str)
95: Thread.Sleep(300)
96: Next
97: Next
98: End Sub
99: End Class
FORM WELCOME
1: Imports System.Threading
2:
3: Public Class F_welcome
4: Inherits System.Windows.Forms.Form
5:
6: Private i As Int16
7: Private cek As Boolean = False
8: Private init As Thread
9:
10: Private Sub F_Welcome_PageLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
11: Dim c As New c_startup
12:
13: init = New Thread(AddressOf c.init)
14: AddHandler c.init_msg, AddressOf init_msg
15: AddHandler c.stopthread, AddressOf stopInit
16: init.IsBackground = True
17: init.ApartmentState = ApartmentState.MTA
18: init.Start()
19: End Sub
20:
21: Sub init_msg(ByVal str As String)
22: 'tampilkan informasi inisialisasi
23: lbl_init.Text = str
24: End Sub
25:
26: Sub stopInit(ByVal close As Boolean)
27: If close Then
28: Me.Close()
29: If init.IsAlive Then
30: init.Abort()
31: End If
32: End If
33: End Sub
Hasil Akhirnya :
0 Whisper
Post a Comment
Please, your comment must related with current posting otherwise your comment will mark as Spam.