I have a wpf application like this :
public CreateProject()
{
InitializeComponent();
_3DCAO.Temporary3DCAO.Close = false;
Userinitial fen = new Userinitial();
container.Content = fen;
Thread windowThread2 = new Thread(delegate() { verifing2(); });
windowThread2.IsBackground = true;
windowThread2.Start();
}
public void verifing2()
{
bool condition_accomplished = false;
while (!condition_accomplished)
{
if (Temporary3DCAO.Etape == 1)
{
_3DCAO.Settings set = new Settings();
if (container.Dispatcher.CheckAccess())
{
container.Content = set;
}
else
{
container.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
{
container.Content = set;
}));
}
condition_accomplished = true;
}
}
}
In the method Verifing
i'd like to instanciate a User Control
_3DCAO.Settings set = new Settings();
But this error appears :
The calling thread must be STA, as required by many components of the user interface
- Why this exception appears?
- How can i fix it?