From 8838a3b20ba95bca34954b6ec828991adb028d4d Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 10 Mar 2025 07:41:43 +0100 Subject: Various work --- ModerationClient/Services/ClientContainer.cs | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'ModerationClient/Services/ClientContainer.cs') diff --git a/ModerationClient/Services/ClientContainer.cs b/ModerationClient/Services/ClientContainer.cs index fa3abef..957e3cc 100644 --- a/ModerationClient/Services/ClientContainer.cs +++ b/ModerationClient/Services/ClientContainer.cs @@ -1,8 +1,40 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; + namespace ModerationClient.Services; public class ClientContainer { - public ClientContainer(MatrixAuthenticationService authService, CommandLineConfiguration cfg) + private readonly ILogger _logger; + private readonly MatrixAuthenticationService _authService; + private readonly CommandLineConfiguration _cfg; + + public ClientContainer(ILogger logger, MatrixAuthenticationService authService, CommandLineConfiguration cfg) { + _logger = logger; + _authService = authService; + _cfg = cfg; + } + + private bool _isRunning = false; + + public void EnsureRunning() + { + if (_isRunning) return; + _isRunning = true; + _ = Task.Run(Run).ContinueWith(t => { + if (t.IsFaulted) + { + _logger.LogError(t.Exception, "Error in client container task"); + } + return _isRunning = false; + }); + } + + private async Task Run() { + Console.WriteLine("Running client view model loop..."); + ArgumentNullException.ThrowIfNull(_authService.Homeserver, nameof(_authService.Homeserver)); } } \ No newline at end of file -- cgit 1.5.1