I have implemented a background service that executes some long process work. A snapshot of how the things are arranged are as follows:
Task.Run(async () =>
{
await DoBackgroundJob();
});
public async Task DoBackgroundJob() {
MatchAndInsertIntoDb(); // call another method
}
The method MatchAndInsertIntoDb
has method signature as follows:
public ObservableCollection<Trucks> MatchAndInsertIntoDb() {
The issue is that when I put breakpoints on each line, the method MatchAndInsertIntoDb()
gets executed properly, when I press F10
on each line.
But when the background service runs without debugging and breakpoints, the method MatchAndInsertIntoDb()
does not seem to be executing properly. The method MatchAndInsertIntoDb()
has a few methods in its body, like querying the local db and performing a match against another list and posting data on a remote web service.
My suspect is that since its a long-running operation, it is not getting sufficient time to complete the execution properly.
Could somebody enlighten me on this issue or help me to resolve it please ?