↓ Skip to main content

>NET Core

Hosted Background timer task

Hosted Background timer task

·1 min
If you need a background task within .Net Core to be run at set times we can use the Hosted Service provided from the service within .Net Core. A timed background task makes use of the System.Threading.Timer class. The timer triggers the task’s DoWork method. The timer is disabled on StopAsync and disposed when the service container is disposed on Dispose:
Hosting a service inside  ASP.NET Core

Hosting a service inside ASP.NET Core

·1 min
A little hidden gem within .Net Core is the ability to run a Hosted Service inside the application. This allows for your service to run in a different thread to the main application, but keeps everything together though the need to host a separate service.
ILogger in .NET: best practices

ILogger in .NET: best practices

·11 mins
If you are like me you will have been using ILogger in DotNet Core for some time, but you’ll have noticed there are many ways to use the logger, I found this useful article by Rico Suter going over some recommendation and best practices.
ASP.NET Core Guidance

ASP.NET Core Guidance

·11 mins
I came across a very good article on ASP.NET Core which I needed to bookmark, as it gives a clear and understandable guidance on keeping things working as efficiently as possible. https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/blob/master/AspNetCoreGuidance.md Here is a copy of the post
Health Checks

Health Checks

·2 mins
Using DotNet Core comes some responsibilities, one of those is making sure your application is up and running. Since DotNet Core 2.2 the introductions of health checks have been established. There are two types of Health Checks
Sample .NET Core Docker file

Sample .NET Core Docker file

·1 min
Here is a working example of a simple Docker file for a .NET Core 3.1 project FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env WORKDIR /app COPY project.csproj ./ RUN dotnet restore COPY . ./ RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/core/runtime:3.1 WORKDIR /app COPY –from=build-env /app/out . ENTRYPOINT [“dotnet”, “project.dll”]