mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-12-15 12:24:57 +01:00
ready for testing
This commit is contained in:
52
ObservatoryCore/UI/ReadAllProgress.cs
Normal file
52
ObservatoryCore/UI/ReadAllProgress.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Observatory.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Observatory.UI
|
||||
{
|
||||
public partial class ReadAllForm : Form
|
||||
{
|
||||
private CancellationTokenSource ReadAllCancel;
|
||||
|
||||
public ReadAllForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var ReadAllJournals = LogMonitor.GetInstance.ReadAllGenerator(out int fileCount);
|
||||
int progressCount = 0;
|
||||
ReadAllCancel = new CancellationTokenSource();
|
||||
HandleCreated += (_,_) =>
|
||||
Task.Run(() =>
|
||||
{
|
||||
foreach (var journal in ReadAllJournals())
|
||||
{
|
||||
if (ReadAllCancel.IsCancellationRequested)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
progressCount++;
|
||||
Invoke(() =>
|
||||
{
|
||||
JournalLabel.Text = journal.ToString();
|
||||
ReadAllProgress.Value = (progressCount * 100) / fileCount;
|
||||
});
|
||||
}
|
||||
Invoke(()=>Close());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
ReadAllCancel.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user