I’ve made an experiment on GOF Factory Method Pattern and use Threads for this.
I used the GOF Factory Method Pattern for dynamically create threads in C# .Net. The code structure is exactly the same described in the Factory Method pattern Example. I know creating new threads is not considered good practice. But sometimes you have to consider some not good enough practices to accomplish your requirements. I need to know that is it safe to create threads dynamically by this pattern or is there any better pattern or technology to create and manage threads in run time??? I am going to implement this in my project where I need to create several Threads in run time.
I’ve made an experiment on GOF Factory Method Pattern and use Threads for this.
Share
As stated by Hans Passant .NET 4.0 TaskFactory Class is a useful tool for creating simultaneous Threads.
A task factory is represented by the System.Threading.Tasks.TaskFactory class, which creates Task objects, or the System.Threading.Tasks.TaskFactory class, which creates Task objects. Both classes contain methods that you can use to:
References: