C# Dispatcher.invoke hangs when the mainthread called thread.join
<p>I am having a problem, for which I am not able to find a solution. The problem is as follows:</p>

<p>in the main thread (the default thread), I am starting a thread and then immediately in the main thread, I wait for the thread's exit by calling thread.join on the spawned thread. When I do that if the spawned thread tries to callback in the main thread's context by calling Dispatcher.Invoke, it hangs. Any ideas how I can allow the callback?</p>

<p>The callback has the logic to signal the thread to exit. Without executing the callback, the thread will never exit, and so the main thread is also stuck.</p>

<p>thanks in advance.</p>
