private void SetIcon(int item, int value) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.lvFiles.InvokeRequired) { SetIconCallback d = new SetIconCallback(SetIcon); try { this.Invoke(d, new object[] { item, value }); } catch (Exception) { } } else { lvFiles.Items[item].ImageIndex = value; } }
void SetIcon(int iIndex, int iIcon) { try { if (!listView1.InvokeRequired) { listView1.Items[iIndex].ImageIndex = iIcon; } else { SetIconCallback d = new SetIconCallback(SetIcon); Invoke(d, new object[] { iIndex, iIcon }); } } catch (Exception) { } }