I need need it to update my ListView before continueing

if (chars.Length > 0)
                    {
                        string log = string.Format("{0}:{1}", acc.Username, acc.Password);
                        UpdateListView();
                        sWorking += log + "\r\n";

                        foreach (IJJIAccount.GunZCharacter gc in chars)
                        {
                            log = string.Format("\t{0} - Level {1}", gc.CharName, gc.Level);
                            sWorking += log + "\r\n";
                        }
                    }

UpdateListView()

void UpdateListView()
        {
            ListViewItem Lvi = new ListViewItem(acc.Username);
            ListViewItem.ListViewSubItem LviPassword = new ListViewItem.ListViewSubItem(Lvi, acc.Password);
            Lvi.SubItems.Add(LviPassword);
            IDC_ListView.Items.Add(Lvi);
        }

Atm it updates it once the thread has finished its business but i need the check to either run on another thread or the update to finish before it continues

Recommended Answers

Answered by cVz 19 in a post from

Yo dude, maybe something like this will work , it works for me ...

Application.DoEvents();
listView1.Refresh();
Jump to Post

All 3 Replies

Yo dude, maybe something like this will work , it works for me ...

Application.DoEvents();
listView1.Refresh();

nope its fine, i just ran it in another thread :)

If you just want to update, calling application.DoEvents can have bad reactions and cause odd things, so, you can just run .Update() which causes a repaint but doesnt cause new bits of code to run :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.