.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Thread.Join in WPF on shutdown

Posted By:      Posted Date: September 21, 2010    Points: 0   Category :WPF

Short version: How do I do thread.Join() in a WPF app without deadlocking the UI?

During the Window_Closing() this application shuts down various threads.  If the GUI calls .Join on them then the UI hangs and gets a deadlock as soon as something calls Dispatch.Invoke().  This happens when a thread tries to update the UI to indicate it was aborted.

What I need is something like the old MsgWaitForMultipleObjects() but in WPF fashion.  It is complicated by the fact that I'm not even sure it is safe or possible to process messages during a Window_Closing() event.

I'm looking for ideas...

View Complete Post

More Related Resource Links

WPF Client App Freezing -- UI Thread Sleep, Wait, Join

Okay, I need some help from the community -- I am about to lose my mind.

I have a .net 3.5SP1 WPF client app that allows field tickets to be written out in the field and synced, using sync services, to our production servers.

Here's the situation:

After my background worker threads have finished their work, the tip of the day goes away and the app freezes randomly a few seconds later.  I can only make it happen about 1 in every 20 times, if that. 


When I view in the debugger, it says the UI thread is "sleeping, waiting for join."  Now, background workers should all play cleanly with the UI thread.  So honestly I don't know if another thread is causing it - I actually even read a borderless Window (which would be my tip of the day screen) could cause it.  But I've removed that and tested and can still generate the issue.


I have tried to figure out what's causing this off and on for a month now and have had no luck.  I have removed what I think may be offending code, to only find out I'm still have the problem.  For example, I've removed a sync image, splash screen, code from background worker, etc.


If anyone has any tools to help identify what threads are hanging my U

Thread Performance: Resource Contention Concurrency Profiling in Visual Studio 2010


Visual Studio 2010 includes new resource contention profiling features that help detect concurrency contention among threads. We walk through a profiling investigation to demonstrate how you can pinpoint and fix resource contention problems in your code.

Maxim Goldin

MSDN Magazine June 2010

Thread Diagnostics: Performance Tuning with The Concurrency Visualizer in Visual Studio 2010


Understanding performance bottlenecks in multithreaded apps used to require significant instrumentation and analysis by expert developers. The Concurrency Visualizer in Visual Studio 2010 significantly reduces the burden of parallel performance analysis.

Hazim Shafi

MSDN Magazine March 2010

CLR Inside Out: Thread Management In The CLR


Getting the performance you want in concurrent applications is not as straightforward as you might think. See how common threading issues can affect your application.

Erika Fuentes and Eric Eilebrecht

MSDN Magazine December 2008

Editor's Note: new Thread(ReadEditorsNote).Start(); yourAttention.WaitOne();


Introducing the issue, Howard Dierking points out that you can't simply parallelize your code blindly if you expect to truly reap the benefits that parallelism promises.

Howard Dierking

MSDN Magazine October 2008

Pooled Threads: Improve Scalability With New Thread Pool APIs


The new threadpool APIs in Windows Vista and in the upcoming Windows Server 2008 provide advances that even native Windows developers can benefit from.

Robert Saccone

MSDN Magazine October 2007

Concurrent Affairs: Build a Richer Thread Synchronization Lock


In my last column, I showed the various thread synchronization mechanisms employed by the Microsoft® . NET Framework (see Concurrent Affairs: Performance-Conscious Thread Synchronization). I then examined the performance characteristics of all these mechanisms and determined that the Interlocked methods performed the best because the calling thread never has to transition to kernel mode.

Jeffrey Richter

MSDN Magazine March 2006

Concurrent Affairs: Performance-Conscious Thread Synchronization


In my career, I have architected and implemented many thread synchronization techniques. This has provided me with a lot of experience that has shaped the way I now think about thread synchronization problems.

Jeffrey Richter

MSDN Magazine October 2005

Basic Instincts: Thread Synchronization


My last three Basic Instincts columns have examined techniques for using asynchronous delegates and creating secondary threads. Those columns demonstrated how to introduce multithreaded behavior into your applications.

Ted Pattison

MSDN Magazine September 2004

.NET Column: The CLR's Thread Pool


How does the thread pool work in the CLR?

Jeffrey Richter

MSDN Magazine June 2003

.NET Column: Safe Thread Synchronization


By far, the most common use of thread synchronization is to ensure mutually exclusive access to a shared resource by multiple threads. In the Win32® API, the CRITICAL_SECTION structure and associated functions offers the fastest and most efficient way to synchronize threads for mutually exclusive access when the threads are all running in a single process.

Jeffrey Richter

MSDN Magazine January 2003

Windows CE 3.0: Enhanced Real-Time Features Provide Sophisticated Thread Handling


Windows CE is a small, configurable, feature-rich, real-time operating system. In Windows CE 3.0, the real-time support has been improved. This article looks at specific support for the creation of real-time systems and how it compares to the support in Windows for the desktop. The way interrupt handlers, processes, memory management, and synchronization work in Windows CE 3.0 is discussed. An extensive look at threads and thread priority, misconceptions surrounding them, and their impact on performance is included. Refinements to the Windows CE scheduler and support for nestable interrupts are also covered.

Paul Yao

MSDN Magazine November 2000

Join Two Tables and Prepare Report



            I have a select query which is executing well. Now, I want to add one more field to that query. That field is not in the current query table, It is in the another table.

How do I join those two tables and get that field value in the existing select query.?


Linq join fields for return data


  how would I join fields together?

           return (from c in storedb.Product_Categories

                         where c.Category_Name.Contains(searchText)
                         orderby c.Category_Name
                         select new {
                                    c.Category_Key && " ;" && c.Category_Name // HOW CAN I DO THIS.....

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend