Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

Object Pool ใน C# คืออะไร

Object Pool เป็น Software Construct เพื่อเพิ่มประสิทธิภาพการใช้ Resource จำกัด มี Object พร้อมใช้งาน

รูปแบบ 2 แบบ:

  • Activate - ดึง Object จาก Pool
  • Deactivate - คืน Object กลับ Pool

ตั้งค่าด้วย ObjectPoolingAttribute บนคลาสที่繼承 System.EnterpriseServices.ServicedComponent

ใช้ Diagnostics ตรวจสอบพฤติกรรม Pool

ประโยชน์: เมื่อ Performance ผูกกับ Resource การสร้างและทำลาย Object บ่อยๆ Object Pool ช่วยเพิ่มประสิทธิภาพ