-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathLoadingForm.cs
More file actions
60 lines (52 loc) · 1.39 KB
/
LoadingForm.cs
File metadata and controls
60 lines (52 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Windows.Forms;
namespace StudentPhotoCollection
{
public partial class LoadingForm : Form
{
public LoadingForm()
{
InitializeComponent();
}
public void CloseForm()
{
if (this.InvokeRequired)
{
//这里利用委托进行窗体的操作,避免跨线程调用时抛异常,后面给出具体定义
CONSTANTDEFINE.SetUISomeInfo UIinfo = new CONSTANTDEFINE.SetUISomeInfo(new Action(() =>
{
while (!this.IsHandleCreated)
{
;
}
if (!this.IsDisposed)
{
this.Dispose();
}
this.Close();
}));
this.Invoke(UIinfo);
}
else
{
if (!this.IsDisposed)
{
this.Dispose();
}
this.Close();
}
}
private void LoadingForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!this.IsDisposed)
{
this.Dispose(true);
}
}
}
//定义一个委托类
class CONSTANTDEFINE
{
public delegate void SetUISomeInfo();
}
}