My app needs to load plugins into separate app domains and then execute some code inside of them asynchronously. I\'ve written some code to wrap Task
in marshallabl
My best guess is that you are facing these issues because of the async method that contains await and this is managed via the ThreadPool which can allocate some recycled Thread.
Reference Best practice to call ConfigureAwait for all server-side code
Actually, just doing an await can do that(put you on a different thread). Once your async method hits an await, the method is blocked but the thread returns to the thread pool. When the method is ready to continue, any thread is snatched from the thread pool and used to resume the method.
Try to streamline the code, generate threads for baseline cases and performance is last.