multithreading - Invoking For Loops VB.Net -


how invoke loop in vb.net?

example:

    each listviewitem listviewitem in me.tasklistview.items         me.executetask(listviewitem, false)     next 

so needs invoked, how go that? not sure how. inside background worker handler , causes invalidoperationexception when inside it. information error is: "cross-thread operation not valid: control 'tasklistview' accessed thread other thread created on."

the error occurs on line:

    each listviewitem listviewitem in me.tasklistview.items 

i overcome problems threads in winforms using following subroutine

public sub guiasync(byval frm form, byval action action)     if action isnot nothing         if frm.invokerequired             frm.invoke(action)         else             action()         end if     end if end sub 

i'd use follows (in case code runs in form , me reference form):

 guiasync(me,     sub()        each listviewitem listviewitem in me.tasklistview.items            me.executetask(listviewitem, false)        next     end sub) 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -