VB.NET Delegate Function returning Boolean value -
i'm using backgroundworker , need utilize delegate function see if listviewitem checked or not maintain recieving cross-thread error. must way i'm writing it. help?
dim dellistviewitemchecked listviewitemcheckeddelegate = addressof listviewitemchecked dellistviewitemchecked.invoke(listviewphotos, 0) private delegate function listviewitemcheckeddelegate(byval listview listview, byval index integer) boolean private function listviewitemchecked(byval listview listview, byval index integer) boolean if listview.items(index).checked = true homecoming true else homecoming false end if end function
try this:
do not pass listview parameter listviewitemcheckeddelegate. declare new delegate instance within dowork handler of background worker.this sample seems work ok:
private delegate function listviewitemcheckeddelegate(byval index integer) boolean private function listviewitemchecked(byval index integer) boolean homecoming listview1.visible end function private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click bkg1.runworkerasync() end sub private sub bkg1_dowork(byval sender system.object, byval e system.componentmodel.doworkeventargs) handles bkg1.dowork dim dellistviewitemchecked new listviewitemcheckeddelegate(addressof listviewitemchecked) msgbox(me.invoke(dellistviewitemchecked, 3)) ' arbitrary 3 end sub
vb.net delegates
No comments:
Post a Comment