Automatically Freezing Threads (Brrrrr)

Looks like many people liked my macros that made multithreaded debugging easier. One of the comments on the article from Sam was worth exploring deeper:

Great post!
Would you have any idea how to make VS do this:

This very common problem comes up the more threads you have. The gist of the problem is that you’re stepping one thread, but all of a sudden, you’re stepping a completely different thread. What’s happening is that the thread your stepping is getting it’s time slice, but your other threads are not so the thread scheduler pulls the thread you’re stepping off the CPU and puts a starving thread on. Hence, it looks like you are bouncing around threads.

The solution proposed in the Stack Overflow question is to freeze the other threads, which is about all you can do. Once stopped in the debugger, open the Threads window and right click on the thread you don’t want to run and select Freeze from the context menu.

In the above screen shot, I already froze thread ID 5788, which is shown by the pause icon in the far left column and the Suspend column has a count of 1. Note that the suspend count could be higher if your code has called Thread.Suspend/SuspendThread on the thread. If you want to freeze multiple threads from the debugger at the same time, hold down the control key and click to multi select. The context menu Freeze works on all selected threads.

That’s great that you can freeze threads like this. However, could you possibly screw up your application doing so? Absolutely! If you’re doing mixed .NET and native debugging and you suspend the garbage collector thread, let’s just say your garbage collections might take approximately forever to finish. Freezing threads is a very powerful technique, but one to use carefully. Many times all you want to do is ensure you step through the end of the current function without bouncing to another thread so freezing all the other threads probably won’t cause any problems as long as you thaw them before you return.

If you have only two threads in your application, it’s easy to freeze the other thread. It gets more tedious if you have many threads in your application. (If you think you have a bunch now, wait until we are all using the new Parallel Task Library coming up in .NET 4.0.) When I’m debugging and want to freeze threads, I always seem to be suspending all the other threads in the program except the active one. As I’m too lazy to manually select all those other threads, I automated thread freezing and thawing with the FreezeAllButActiveThread and ThawAllFrozenThread macros below for your enjoyment. Note that the Threads window sometimes doesn’t update after running these macros to show the new state.

Is there anything else you want to see automated while debugging? How about with Visual Studio itself? If so, ask away in the comments or send me an email. Consider me your personal developer! <grin>


' Wintellect Debugging Code
' Copyright © 1997-2009 John Robbins
            -- All rights reserved. 
' Freeze and thaw threads in bulk.
' Version 1.0 - July 17, 2009
' - Initial version. 
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports System.Text
Imports System.Collections.Generic
Imports System.Runtime.InteropServices
Imports System.Windows.Forms

Public Module FreezeThawThreads

    Public Sub FreezeAllButActiveThread()

        Dim dbg As EnvDTE90.Debugger3 = DTE.Debugger
        If dbg.CurrentMode = dbgDebugMode.dbgBreakMode Then
            Dim currProg As Program = dbg.CurrentProgram
            For Each t As Thread2 In currProg.Threads
                If (t.ID <> dbg.CurrentThread.ID) Then
                    If t.IsFrozen = False Then
                    End If
                End If
        End If

    End Sub

    Public Sub ThawAllFrozenThreads()
        Dim dbg As EnvDTE90.Debugger3 = DTE.Debugger
        If dbg.CurrentMode = dbgDebugMode.dbgBreakMode Then
            Dim currProg As Program = dbg.CurrentProgram
            For Each t As Thread2 In currProg.Threads
                If t.IsFrozen = True Then
                End If
        End If
    End Sub

    Private Sub NotInBreakMode()
        MessageBox.Show(New MainWindow(), _
                        "You must
            be stopped in the debugger for this macro to work", _
            Thread Freeze/Thaw Macros", _
                        MessageBoxButtons.OK, _
    End Sub

    ' A helper class so I can parent
            message boxes correctly on the IDE.
    Class MainWindow
        Implements IWin32Window

        Public ReadOnly Property Handle() _
                            As System.IntPtr Implements IWin32Window.Handle
                ' The HWnd property
            is undocumented.
                Dim ret As IntPtr = CType(DTE.MainWindow.HWnd, IntPtr)
                Return (ret)
            End Get
        End Property
    End Class

End Module


Atmosera Introduces Three-Tier Azure Management Suite for the Enterprise

Fully Managed, Co-Managed, and Self-Managed Azure Solutions Now Available to Business Customers Through the Company’s Enterprise Agreement or Microsoft CSP Licensing Format

Read Press Release

News Summary

PORTLAND, OR — May 29, 2018 — Atmosera a premier Tier-I Microsoft Cloud Solution Provider (CSP), today announced the company’s Three Tier Azure Management Suite to strategically align Atmosera managed service levels with business objectives, expertise, and their existing IT investment. A leading provider for the cloud enablement of business applications, Atmosera now provides co-managed and self-managed Azure solutions in addition to its fully managed solution suite. Atmosera provides these options via a customer’s existing Enterprise Agreement (EA) or via the Atmosera CSP licensing format.

The new portfolio offers customers diversity of choice for the oversight and management of compute, storage, networking, security, support, and engineering relative to a wide range of cloud-based IT solutions powered by Azure.

According to Synergy Research Group, spending on cloud infrastructure services in the last quarter of 2017 jumped 46 percent, comfortably beating the growth rates achieved in the previous three quarters.(i) Microsoft led the pack in terms of cloud growth. For its quarter ending Dec. 31, 2017, Microsoft reported revenues from Azure increased 98 percent.(ii)

Microsoft’s constantly-expanding worldwide network of data centers is the foundation behind Azure, the cloud platform for hosting applications on-demand. Atmosera provides the infrastructure and intelligence to support organizations in cloud-enabling their IT operations on Azure through the company’s managed, co-managed, or self-managed models leveraging Azure’s Infrastructure-as-a-Service (IaaS) or more frequently, Platform-as-a-Service (PaaS) functionalities. Atmosera’s Three-Tier Azure Management portfolio empowers IT with a powerful, reliable, and secure set of computing alternatives for deploying a vast array of computing workloads.

Atmosera’s Three-Tier Azure Management portfolio includes:

Fully Managed Solutions: Customers benefit from having a cloud solution provider who supports and manages IaaS and PaaS services through the OS layer and, optionally, to the middleware and database layers.

Co-Managed Solutions: Customers select the services they want to perform on their own and which ones will be handled by Atmosera. This creates a split responsibility matrix with defined, automated runbooks which allow the customer to retain as much or as little control as they require.

Self-Managed Solutions: For self-managed Azure services, enterprise IT staff provides 24x7x365 oversight to operate their compute, network and storage resources. With this approach, Atmosera is responsible for infrastructure availability. The management of the OS, middleware and database is overseen by the customer.

The Atmosera three-tier Azure management suite introduces customized levels of outsourced IT support for organizations seeking to lower operational costs, reduce risk, improve system reliability, and rest assured that skilled experts will operate as a trusted extension of their team. Atmosera provides greater flexibility with these service levels to reduce the extensive resource requirements of IT, allowing customers to focus on the core areas of their business.

“Many companies have an existing investment in IT resources, capabilities, or licensing. Our approach is that we’ll meet you where you need and want to be met, ending the limits that traditional IT has imposed on businesses,” said Jon Thomsen, CEO, Atmosera. “Our Azure-based cloud solutions overcome the challenges and hidden costs of managing a cloud environment to support increased productivity and long-term success.”

Find Out More: visit the three-tier Azure management portfolio page and download the data sheet at

Tweet This: @Atmosera Introduces Three-Tier Azure Management Suite for the Enterprise #Azure #Cloud

– Contact Atmosera today at:
– Follow Atmosera on Twitter at:
– Follow Atmosera on LinkedIn at:

About Atmosera
With over 20 years of industry experience, Atmosera is a leading provider of business-class Microsoft cloud managed services. Award-winning Atmosera Managed Azure Services simplify the process of transitioning from legacy three-tier IT architecture to the Microsoft Cloud Platform for improved IT transparency, security, and trust. Atmosera is a 100% focused on Microsoft and is a Gold Level Tier 1 CSP with Microsoft COSN and Azure Certified for Hybrid designations. With hundreds of customers worldwide, Atmosera service capabilities span the globe and reach across every business sector. To learn more about Atmosera Managed Azure Services, please visit or call +1.800.903.4852.

– END –

Contact Atmosera
+1.503.222.2202 or +1.800.903.4852 |

(i) Synergy Research Group, Cloud Growth Rate Increases; Amazon, Microsoft & Google all Gain Market Share,
(ii) Microsoft, Microsoft Cloud growth fuels second quarter results, January 31, 2018,

We deliver solutions that accelerate the value of Azure.

Ready to experience the full power of Microsoft Azure?

Start Today

Blog Home

Stay Connected

Upcoming Events

All Events