vb.net中的对象池 [英] Object pooling in vb.net

查看:119
本文介绍了vb.net中的对象池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要在vb.net中实现对象池.请告诉我如何在vb.net中实现这一目标.任何示例代码都很棒.

在Advance中致谢

Hi,

I need to implement object pooling in vb.net. Please advise me how to achieve this in vb.net. Any sample code would be great.

Thanks in Advance

推荐答案

您尝试了什么?基本上,您只想保留一个不再使用的对象列表,然后当您再次需要一个对象时,而不是从头开始构造它,只需从列表中获取即可.如果列表为空,则仅创建一个新列表.完成对象后,将其添加回列表中.
What have you tried? Basically, you just want to keep a list of objects that are no longer in use, then when you need one again, rather than constructing it form scratch, you can just take it from the list. If the list is empty, only then do you create a new one. When you are done with the object, add it back to the list.


是的,我正在寻找相同的东西. vb.net中是否有任何内置的libraray可以实现相同的目的?
Yes I am looking for the same thing. Is there any inbuilt libraray available in vb.net to achieve the same ?


否,但是这是一种过于复杂的方法.为了您的需要,我会选择第一个链接.
No, but here is an example of how to do it (it''s pretty trivial to implement). If you used generic types with that example, you could have one class as an object pool for all your types. Also, here is an overcomplicated way of doing it. For your needs, I''d just go with the first link.


这篇关于vb.net中的对象池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆