所以我在vb.net中运行了多个线程。我需要知道,如何添加到“在不同的线程中创建”的列表框?我似乎无法克服这个错误!
确切错误:
System.InvalidOperationException occurred
HResult=0x80131509
Message=Cross-thread operation not valid: Control 'ListBox2' accessed from a thread other than the thread it was created on.
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.ListBox.NativeAdd(Object item)
at System.Windows.Forms.ListBox.ObjectCollection.AddInternal(Object item)
at System.Windows.Forms.ListBox.ObjectCollection.Add(Object item)
at SuperBC_Check_Pro.Form1.IncluBC(String username, String membershipType) in C:\Users\Owner\documents\visual studio 2017\Projects\SuperBC-Check Pro\SuperBC-Check Pro\Form1.vb:line 64
at SuperBC_Check_Pro.Form1.CheckBCMembership() in C:\Users\Owner\documents\visual studio 2017\Projects\SuperBC-Check Pro\SuperBC-Check Pro\Form1.vb:line 92
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
你们有什么建议我去解决这样的错误?