-Aggiunta configurazione di pubblicazione come servizio windows

This commit is contained in:
2025-06-22 15:58:59 +02:00
parent 33bd5e2bbf
commit 207d6fc845
3 changed files with 36 additions and 0 deletions
@@ -0,0 +1,31 @@
using System;
namespace Data_Coupler.BackgrounServices;
public class BackgroundServices : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
try
{
// Qui puoi inserire il codice che vuoi eseguire in background
// Ad esempio, puoi chiamare un metodo per eseguire operazioni periodiche
// Simula un'attività di lunga durata
await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);
}
catch (OperationCanceledException)
{
// Gestisci l'eccezione se il task viene cancellato
break;
}
catch (Exception ex)
{
// Gestisci altre eccezioni
Console.WriteLine($"Errore: {ex.Message}");
}
}
}
}