mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 08:36:11 +02:00
- Introduced HexColorHelper for parsing hex color strings to Terminal.Gui Attributes and Colors. - Created ChannelListSource for managing and rendering a list of channels with unread counts and active indicators. - Developed UserListSource for displaying online users with per-user nickname colors. - Refactored MainWindow to utilize ChatMessageManager for handling messages and channel state. - Updated project references and removed unused content from the server project. - Adjusted tests to reflect changes in namespaces and structure.
33 lines
824 B
C#
33 lines
824 B
C#
using Serilog;
|
|
using Terminal.Gui.App;
|
|
|
|
namespace EchoHub.Client.Services;
|
|
|
|
/// <summary>
|
|
/// Eliminates repeated Task.Run/try/catch/app.Invoke(ShowError) boilerplate.
|
|
/// Runs async work on a background thread and routes exceptions to the UI.
|
|
/// </summary>
|
|
public static class AsyncRunner
|
|
{
|
|
public static void Run(
|
|
IApplication app,
|
|
Func<Task> work,
|
|
Action<string> showError,
|
|
string errorPrefix,
|
|
string? logContext = null)
|
|
{
|
|
Task.Run(async () =>
|
|
{
|
|
try
|
|
{
|
|
await work();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Error(ex, "{Context} failed", logContext ?? errorPrefix);
|
|
app.Invoke(() => showError($"{errorPrefix}: {ex.Message}"));
|
|
}
|
|
});
|
|
}
|
|
}
|