-6

我有一个包含很多项目的列表视图。我想删除一些同步的项目。那可能吗?我有大约 100 个线程同时访问 ListView 以删除其中的项目。

例如:

 procedure Thread1 ; stdcall;
 var
  item : TlistItem;
 begin
  //...
  item.delete;
  //...
 end;

 procedure Thread2 ; stdcall;
 var
  item : TlistItem;
 begin
  //...
  item.delete;
  //...
 end;

 /.... and so on

线程同时被触发(它们之间可能相差 1ms)。然后我得到很多错误和AccessViolations。请帮忙。谢谢 :)

4

1 回答 1

3

If I were you, I'd create a data structure that the main application thread and all the update threads have access to, and that can be synchronised, and that ONLY the main app thread uses to update the VCL control, if this is the way you need to go.

于 2012-05-31T07:43:23.953 回答