Browsing Month: October 2020

Implement a simple timer using CountDownTimer in Android using Kotlin or Java

In this post, I will be covering how to Implement a simple timer using CountDownTimer in Android using Kotlin or Java. Android provides a utility class called CountDownTimer that you use to implement the timer. Schedule a countdown until a time in the future, with regular notifications on intervals that are set. Implementing CountDownTimer in Kotlin Android […]

How to resolve Cannot access a disposed object in Dotnet Core when injecting DbContext

Accessing DbContext after it is disposed will cause a “Cannot access a disposed object in dotnet Core when injecting DbContext” error. Entity Framework (EF) Core is a lightweight, open-source. EF Core can serve as an object-relational mapper (O/RM). A DbContext instance represents a session with the database and can be used to query and save […]

Implement background tasks using IHostedService and access scoped service using IServiceScopeFactory

It is easy to implement Background tasks and scheduled work using IHostedService and the BackgroundService class. Sometimes it is required certain work to be offloaded when a Web API request is processed. That work could be accessing database records and update some information on some tables based on existing data. In this post, I’m going […]