Click here to Skip to main content
15,886,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to add UserControl in panel with new Thread?
C#
splitContainer1.Panel1.Controls.Add(FaceConEnter);
splitContainer1.Panel2.Controls.Add(FaceConExit);
Posted
Comments
Sergey Alexandrovich Kryukov 1-May-15 10:52am    
UserControl? Which one? Full type name, please. I understand that the actual type is your class derived from UserControl; of course, I'm not interested in its full name. What is the full name of the base type *.UserControl? In other words, what is the UI library? (And then the solution is simple.)
—SA

1 solution

It's not good not to give use full type name, such as full name of UserControl, at least once — please see my comment to the question.

You cannot call anything related to UI from non-UI thread. Instead, you need to use the method Invoke or BeginInvoke of System.Windows.Threading.Dispatcher (for both Forms or WPF) or System.Windows.Forms.Control (Forms only).

You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke(),
Problem with Treeview Scanner And MD5.

See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net,
Control events not firing after enable disable + multithreading.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900