Keep UI responsive during sync (run engine off the UI thread)

Beim Tray-/Auto-Sync lief die Engine auf dem UI-Thread -> Fenster und
Tray-Kontextmenue froren ein (Menuepunkte reagierten nicht).

- MainForm.RunSync fuehrt die Engine jetzt via Task.Run im Hintergrund aus
  (wie schon der manuelle Fenster-Sync).
- Balloon() marshalled Tray-Meldungen thread-sicher per BeginInvoke auf den
  UI-Thread (die Fortsetzung kann nach Task.Run aus einem Pool-Thread kommen).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-17 13:29:49 +02:00
co-authored by Claude Opus 4.8
parent da20d341d7
commit 844094d5c5
2 changed files with 15 additions and 2 deletions
+5
View File
@@ -21,6 +21,11 @@ Versionsschema ist `x.x.x.x` (siehe `release.sh`).
### Behoben
- **Oberflaeche friert waehrend des Syncs nicht mehr ein.** Beim Tray-/Auto-Sync
lief die Sync-Engine auf dem UI-Thread, wodurch Fenster und Tray-Kontextmenue
blockierten (Menuepunkte reagierten nicht). Die Engine laeuft jetzt im
Hintergrund (`Task.Run`), die Tray-Meldungen werden thread-sicher auf den
UI-Thread marshalled.
- **Dubletten bei Firmen-/Service-Eintraegen (nur Nummer + Firma).** Solche
Eintraege wurden bei jedem Sync neu angelegt statt verknuepft, weil der
Nummern-Abgleich feldgenau (geschaeftlich↔geschaeftlich) und formatabhaengig
+10 -2
View File
@@ -358,9 +358,11 @@ namespace StarfaceOutlookSync.UI
{
// Lokaler Guard, Lock-Datei, Konflikt-Notizen und Protokoll laufen
// zentral im Coordinator (gemeinsam mit dem manuellen Sync-Pfad).
// WICHTIG: die Engine im Hintergrund laufen lassen, damit das
// Fenster und das Tray-Kontextmenue waehrend des Syncs reagieren.
var outcome = await _coordinator.RunAsync(
profile,
runEngine: () => _syncEngine.SyncProfileAsync(profile),
runEngine: () => Task.Run(() => _syncEngine.SyncProfileAsync(profile)),
status: SetStatus);
if (outcome.Skipped)
@@ -426,7 +428,13 @@ namespace StarfaceOutlookSync.UI
private void Balloon(int ms, string title, string text, ToolTipIcon icon, bool warn)
{
bool allow = warn ? _notifyWarn : _notifyGeneral;
if (allow) _trayIcon.ShowBalloonTip(ms, title, text, icon);
if (!allow) return;
if (InvokeRequired)
{
BeginInvoke(new Action(() => _trayIcon.ShowBalloonTip(ms, title, text, icon)));
return;
}
_trayIcon.ShowBalloonTip(ms, title, text, icon);
}
private void SetStatus(string text)