vb.net - Getting cross thread Error even Used Invoke -
getting cross thread error when executing tcviewer.tabpages.add(t)
statement.
code below.
private function fff(t tabpage) tcviewer.tabpages.add(t) 'giving cross thread error end function function webbrowserthread() dim t tabpage = new tabpage((k + 1).tostring()) t.name = k.tostring() tcviewer.invoke(fff(t)) end function
please guide.
i think should move creation of new tabpage
onto ui thread well:
private function fff(k integer) dim t tabpage = new tabpage((k + 1).tostring()) t.name = k.tostring() tcviewer.tabpages.add(t) end function function webbrowserthread() tcviewer.invoke(fff(k)) end function
when construct tabpage
, reach call stack:
system.windows.forms.dll!system.windows.forms.control.createhandle() system.windows.forms.dll!system.windows.forms.application.marshalingcontrol.marshalingcontrol() system.windows.forms.dll!system.windows.forms.application.threadcontext.marshalingcontrol.get() system.windows.forms.dll!system.windows.forms.windowsformssynchronizationcontext.windowsformssynchronizationcontext() system.windows.forms.dll!system.windows.forms.windowsformssynchronizationcontext.installifneeded() system.windows.forms.dll!system.windows.forms.control.control(bool autoinstallsynccontext) system.windows.forms.dll!system.windows.forms.scrollablecontrol.scrollablecontrol() system.windows.forms.dll!system.windows.forms.panel.panel() system.windows.forms.dll!system.windows.forms.tabpage.tabpage() system.windows.forms.dll!system.windows.forms.tabpage.tabpage(string text)
at point, handle
being created, , if you're doing on wrong thread, else going start going wrong (because thread control created on isn't going run message pump)
Comments
Post a Comment