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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -