-
Notifications
You must be signed in to change notification settings - Fork 0
/
SplashForm.cs
61 lines (54 loc) · 1.71 KB
/
SplashForm.cs
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
61
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace InventoryManagement
{
public partial class SplashForm : Form
{
public SplashForm()
{
InitializeComponent();
}
private Task ProcessData(List<string> list, IProgress<ProgressReport> progress)
{
int index = 1;
int totalProcess = list.Count();
var progressReport = new ProgressReport();
return Task.Run(()=> {
for (int i = 0; i < totalProcess; i++)
{
progressReport.PercentComplete = index++ * 100 / totalProcess;
progress.Report(progressReport);
Thread.Sleep(10);
}
});
}
private async void SplashForm_Load(object sender, EventArgs e)
{
List<string> list = new List<string>();
for (int i = 0; i < 1000; i++)
{
list.Add(i.ToString());
}
statusLbl.Text = "Working...";
var progress = new Progress<ProgressReport>();
progress.ProgressChanged += (o, report) =>
{
statusLbl.Text = String.Format("Processing...{0}%", report.PercentComplete);
progressBar.Value = report.PercentComplete;
progressBar.Update();
};
await ProcessData(list, progress);
Form1 login = new Form1();
this.Hide();
login.Show();
}
}
}