c# - PerThreadLifetimeManager in Unity -


In the Unity PerThreadLifetimeManager documentation, I have read that: " This lifetime manager does not dispose of those examples Who keeps it ". Ref:

So, if I am using Threadpool, does it mean that at ThreadPool's thread, at the end of the work done in the thread before solving the objects that use Unity Will not be disposed of for the pool?

Any pattern or idea how can I ensure that the objects will be dealt & amp; Do I get a clean thread from the thread pool?

Thank you!

It depends on the life-manager's type PerThreadLifetimeManager Keeps the thread There are six managers available throughout the lifetime, but that does not mean that you can not make yourself if they are not in accordance with you.

It seems that you want a new example per call. You can resolve your worker within the thread, use the example, and you can settle it before the exit of the law.

I'm not sure that you can make a lifelong manager, which in some way will automatically know that your thread has completed the execution. The best way to ensure that a method is to create the cover is 1) Take the example using Unity (Transient Lifetime Manager), in the example an Action & Lt; T> (your actual worker method), and then it removes it before leaving the example. Then you will execute it by carrying it to its cover, which is run on a worker thread. You only have to type your resolution () and the displacement () code and it must be reused everywhere.


Comments