0
private void ItemGet()
{
    for (int i = 0; i < this.listview2.VirtualListSize; i++)
    {
        var address = this.listview2.Items[i].Text;
        int item_aid = this.lib.ReadInt32((IntPtr)(long.Parse(address, NumberStyles.HexNumber) + ItemData.oFFSET_AID));
        int item_id = this.lib.ReadInt32((IntPtr)(Convert.ToInt32(address, 16) + ItemData.oFFSET_ID));
        int item_type = this.lib.ReadInt32((IntPtr)(Convert.ToInt32(address, 16) + ItemData.oFFSET_TYPE));

        if ((item_aid.ToString().Length == 6) && (item_aid > 110000 && item_aid < 200000) 
            && item_id.ToString().Length == 3 - 6)
        {
            this._itemslist.Add(new ItemResults(item_aid, item_aid, item_type));
            this.ItemDetailsListView.Items.Add(new ListViewItem(new string[] { 
                item_aid.ToString(), 
                item_id.ToString(),
                item_type.ToString()}));
            MessageBox.Show(item_aid.ToString());
        }
    }
}

when i put messagebox show the messaage box is not pop i use cheat engine library to scan value and put it on listview I have no idea why it's not working

private void ScanTimer_Tick(object sender, EventArgs e)
{
    this.ScanTimer.Enabled = false;

    this.lib.iResetValues();
    this.listview1.Refresh();
    this.listview2.Refresh();

    if (this.started)
    {
        var t = Task.Factory.StartNew(() => GetMonster()).ContinueWith((itemgetTask) => ItemGet()).ContinueWith((attackTask) => Attacks()).ContinueWith((teleportTask) => Teleport()).ContinueWith((pickuptTask) => Pickup());
        Task.WaitAll(t);

        this.lib.iNewScan();
        MonsterScannerTimer.Start();
        ItemScannerTimer.Start();
    }
}

i call it here.

radbyx
  • 9,352
  • 21
  • 84
  • 127
  • You have to add items in UI thread. Try to [invoke](https://stackoverflow.com/q/6650691/1997232) `Items.Add`. – Sinatr Feb 11 '19 at 12:45
  • sorry i dont get it.i think ItemGet() is not working or what? if it's working the messagebox will pop up. – Anden Castillo Feb 11 '19 at 12:55
  • int item_aid = this.lib.ReadInt32((IntPtr)(long.Parse(address, NumberStyles.HexNumber) + ItemData.oFFSET_AID)); MessageBox.Show(item_aid.ToString()); But i got 0 but in cheat engine 7034 – Anden Castillo Feb 11 '19 at 13:10
  • I don't understand what you are trying to say. You can [edit] your question to add missing details, clarifications, obtained/expected results, etc. Do you use `MessageBox` to debug? Rather set breakpoints (on the first line of method, on the line with `Items.Add`, etc.) and observe local variables, parameters, call stack, etc.. – Sinatr Feb 11 '19 at 13:15

1 Answers1

0

First time answering a question, I hope I can help.

Maybe you would be better off with storing the data you would normally add directly to your list into a ObservableCollection.

Here is a link to the class: https://learn.microsoft.com/de-de/dotnet/api/system.collections.objectmodel.observablecollection-1?view=netframework-4.7.2

There are plenty of ways to add it to your listview.

dustin-we
  • 498
  • 2
  • 7