blob: 957e3ccd5a78f178259e9995827d347c69c27431 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
namespace ModerationClient.Services;
public class ClientContainer {
private readonly ILogger<ClientContainer> _logger;
private readonly MatrixAuthenticationService _authService;
private readonly CommandLineConfiguration _cfg;
public ClientContainer(ILogger<ClientContainer> 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));
}
}
|