-Aggiunta configurazione di pubblicazione come servizio windows
This commit is contained in:
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user