ObjectPool or similar for .NET already in a library?

前端 未结 5 1970
余生分开走
余生分开走 2021-01-30 18:38

I don\'t want to write my own because i\'m afraid i might miss something and/or rip off other people\'s work, so is there an ObjectPool (or similar) class existing in a library

5条回答
  •  抹茶落季
    2021-01-30 19:21

    In the upcoming version of .NET (4.0), there's a ConcurrentBag class which can easily be utilized in an ObjectPool implementation; in fact the there's an article on MSDN that shows you how to do precisely this.

    If you don't have access to the latest .NET framework, you can get the System.Collections.Concurrent namespace (which has ConcurrentBag) in .NET 3.5 from Microsoft's Reactive Extensions (Rx) library (in System.Threading.dll).

提交回复
热议问题