change program to async/await
This commit is contained in:
parent
387480b2cf
commit
1b7fb26bc4
@ -1 +1 @@
|
||||
Subproject commit f21bf5ea5e3116fb1ec44bb90d2917506862d66e
|
||||
Subproject commit ed68876300b2b32b97c2dfc436f3fb98e7f1a45d
|
@ -25,7 +25,7 @@ internal class Colony : ITreeNode {
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return $" ☀ {System.Name}";
|
||||
return $" {System.Name}";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,6 @@ internal class Depot : ITreeNode {
|
||||
|
||||
public override string ToString() {
|
||||
string percent = (Progress * 100.0).ToString("00.0");
|
||||
return String.Format($" ⚓ {percent}% {Station.Name}");
|
||||
return String.Format($" {percent}% {Station.Name}");
|
||||
}
|
||||
}
|
||||
|
38
src/Edith.cs
38
src/Edith.cs
@ -22,6 +22,8 @@ internal class Edith {
|
||||
private static Edith instance = new();
|
||||
public static Edith Instance => instance;
|
||||
|
||||
private bool quit = false;
|
||||
|
||||
private Edith() {
|
||||
}
|
||||
|
||||
@ -39,7 +41,32 @@ internal class Edith {
|
||||
}
|
||||
}
|
||||
|
||||
public void Run() {
|
||||
private async Task ProcessQueue() {
|
||||
while (watcher != null) {
|
||||
watcher.ProcessQueues();
|
||||
await Task.Delay(100);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RunGUILoop() {
|
||||
RunState state;
|
||||
bool first = true;
|
||||
|
||||
if (window == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
state = Application.Begin(window);
|
||||
|
||||
while (!quit) {
|
||||
Application.RunLoop(state);
|
||||
await Task.Delay(100);
|
||||
}
|
||||
|
||||
Application.End(state);
|
||||
}
|
||||
|
||||
public async Task Run() {
|
||||
try {
|
||||
SetupJournal();
|
||||
} catch (Exception e) {
|
||||
@ -47,10 +74,15 @@ internal class Edith {
|
||||
return;
|
||||
}
|
||||
|
||||
Application.Init();
|
||||
|
||||
window = new MainWindow();
|
||||
|
||||
Application.Init();
|
||||
Application.Run(window);
|
||||
Task gui = Task.Run(RunGUILoop);
|
||||
Task queue = Task.Run(ProcessQueue);
|
||||
|
||||
await Task.WhenAll([gui, queue]);
|
||||
|
||||
window.Dispose();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args) {
|
||||
Edith.Instance.Run();
|
||||
public static async Task Main(string[] args) {
|
||||
await Edith.Instance.Run();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user