The other night I was working on a new E Foqus App that’s coming out soon on AppSource, and I noticed some strange behaviour. There were operations that simply didn’t happen on a couple of docker containers, but worked great on a cloud sandbox.
I started debugging but ended in a blind spot, where the debugger would not debug the running code?
After a bit more investigation, I discovered, that the code was actually being spawned out as a task. In NAV 2017 we gained a new way of executing code in parallel by starting a task. It’s done with the TaskScheduler.CreateTask method. The problem was, that the task never ran? The CreateTask method does not fail with an ERROR but continues happily as if the task was successfully spawned.
Business Central now has several features throughout the application that requires the TaskScheduler present for the feature to work.
I took a quite look at the awesome navcontainerhelper from Freddy, and according to the documentation, the task scheduler should be running:
I thought I’m on a way newer version of navcontainer than 0.0.5.5, hmmm… perhaps not by default in my case, so I created a new docker container and added the -taskscheduler option to new-navcontainer:
Now all the business logic that required the task scheduler is working and my container is behaving the same way as a cloud sandbox.
So the moral of this story is, remember to add -enableTaskScheduler to your container creation.