I have to deal with a strange problem, at least from my point of view. I use a Task to wait untill a variable gets a specific value and then run the Continue part on the ui thread again.
Problem now is that before I call StartNew() and inside the call the ManagedThreadId is the same and it freezes my UI.
Here my code:
// ManagedThreadId here
Task.Factory.StartNew(() =>
{
// and here are the same.
while (isClosing)
{
Thread.Sleep(50);
}
}).ContinueWith((finishedTask) =>
{
if (currentContainer != null)
{
window = currentContainer;
}
else
{
window = CreateBallonWindow();
window.Show();
}
window.Activate();
}, TaskScheduler.FromCurrentSynchronizationContext());
Ideas?
Thanks Christoph
EDIT:
Most interesting for me is why this happens not how to get around this issue. I want to understand what happens there...