Hi,
I have a console application scheduled on windows server but when the task start the window console appear.
So i ha ve two ways:
1-hide the console windows
2-create a windows service
I prefer the second option so in in net core 6 which is the best practice to do that?
My program.cs is this:
using MyConsoleApp.Contexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace MyConsoleApp
{
public class Program
{
static void Main(string[] args)
{
using (var dbContext = new DataContext())
{
var dwhservice = new MyDataService(dbContext);
dwhservice.CopyRecords();
}
}
#region property
public IConfiguration Configuration { get; }
public Program(IConfiguration configuration)
{
Configuration = configuration;
}
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<DataContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DataConnection"), o => o.CommandTimeout(600)));
}
#endregion
}
}
Thanks