我試圖使圖像檢索器與列表一起工作。圖像檢索器中的線程
該列表包含例如類型(TItem)的項目。 TItem有一些屬性,如標題,圖像和imageURL。
有一個列表中的線程掃描所有項目,並嘗試通過使用每個項目的imageURL檢索每個項目的圖像。
是檢索每個項目的工作像這樣的形象螺紋:
while not terminated do
begin
for i := 0 to List.count-1 do
begin
item := List.Items[i];
//Note : it can takes a few sec to retrieve the image from the imageURL. This method
//retrieve the image from the item.imageURL and then assign it to item.image
RetrieveImage(item.imageURL, item.Image);
end;
sleep(100);
end;
不幸的是,它並沒有在一種情況下工作:當列表被清除,該項目的圖像被檢索由線程。
(所有項目的讀寫受互斥鎖保護)。
我該怎麼辦?
謝謝:)
謝謝!此解決方案有效:) – Ariel32 2009-10-08 07:52:40