-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignalRProgressBar
More file actions
35 lines (28 loc) · 1.5 KB
/
SignalRProgressBar
File metadata and controls
35 lines (28 loc) · 1.5 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
// Show progress bar
var currentUserName = "DOMAIN\\XXX";
var jobName = "xxxx";
PushMessageEmitter.ProgressBarNotifyStart(currentUserName, jobName);
// Submit webservice call and spawn task to blindly update progress bar simultaneously
CancellationTokenSource cts = new CancellationTokenSource();
var result2 = await new [] {
Task.Run<bool>(async () =>
{
for (int i = 1; i < 10; i++)
{
await Task.Delay(TimeSpan.FromSeconds(1), cts.Token);
PushMessageEmitter.ProgressBarNotifyProgress(currentUserName, jobName, i * 10);
}
return false;
}, cts.Token),
Task.Run<bool>(async () =>
{
await Task.Delay(TimeSpan.FromSeconds(8), cts.Token);
return true;
}, cts.Token)
}
.Select(t => t.ToObservable())
.Merge()
.FirstOrDefaultAsync(success => success);
PushMessageEmitter.ProgressBarNotifyProgress(currentUserName, jobName, 100);
PushMessageEmitter.ProgressBarNotifyEnd(currentUserName, jobName);
cts.Cancel();