NewsBot
1
Ever wondered how much time you spend waiting for Visual Studio to respond?
Well its been driving me nuts for a while so I wrote a little app to tracks the time that VS 2008 spends "not responding".
I think you'll be shocked by the results on solutions with 15+ projects.
Hopefully making this information available to others will motivate Microsoft to fix these problems.
Heres the code for your enjoyment (tested with VS 2008)..
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
namespace CalulateHangTime
{
[Flags]
public enum SendMessageTimeoutFlags : uint
{
SMTO_NORMAL = 0x0000,
SMTO_BLOCK = 0x0001,
SMTO_ABORTIFHUNG = 0x0002,
SMTO_NOTIMEOUTIFNOTHUNG = 0x0008
}
public static class ExternalMethods
{
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg,
UIntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags fuFlags,
uint uTimeout, out UIntPtr lpdwResult);
}
class Program
{
static readonly uint WAIT_MILLISECONDS = 2;
static readonly int SLEEP_MILLISECONDS = 1000;
static void Main(string[] args)
{
long seconds = 0;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
while (true)
{
IntPtr hWnd = ExternalMethods.FindWindow("wndclass_desked_gsk", null);
if (hWnd == IntPtr.Zero)
throw new InvalidOperationException("Handle to window could not be found");
UIntPtr result;
IntPtr success = ExternalMethods.SendMessageTimeout(hWnd, 0, UIntPtr.Zero, IntPtr.Zero,
SendMessageTimeoutFlags.SMTO_ABORTIFHUNG, WAIT_MILLISECONDS, out result);
if (success == IntPtr.Zero)
{
seconds += SLEEP_MILLISECONDS / 1000;
Console.WriteLine("Visual Studio is hung. {0}/{1} seconds wasted", seconds, stopWatch.Elapsed.TotalSeconds);
}
else
{
Console.WriteLine("Visual Studio is running fine.");
}
Thread.Sleep(SLEEP_MILLISECONDS);
}
}
}
}
More...
View All Our Microsoft Related Feeds
Well its been driving me nuts for a while so I wrote a little app to tracks the time that VS 2008 spends "not responding".
I think you'll be shocked by the results on solutions with 15+ projects.
Hopefully making this information available to others will motivate Microsoft to fix these problems.
Heres the code for your enjoyment (tested with VS 2008)..
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
namespace CalulateHangTime
{
[Flags]
public enum SendMessageTimeoutFlags : uint
{
SMTO_NORMAL = 0x0000,
SMTO_BLOCK = 0x0001,
SMTO_ABORTIFHUNG = 0x0002,
SMTO_NOTIMEOUTIFNOTHUNG = 0x0008
}
public static class ExternalMethods
{
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg,
UIntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags fuFlags,
uint uTimeout, out UIntPtr lpdwResult);
}
class Program
{
static readonly uint WAIT_MILLISECONDS = 2;
static readonly int SLEEP_MILLISECONDS = 1000;
static void Main(string[] args)
{
long seconds = 0;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
while (true)
{
IntPtr hWnd = ExternalMethods.FindWindow("wndclass_desked_gsk", null);
if (hWnd == IntPtr.Zero)
throw new InvalidOperationException("Handle to window could not be found");
UIntPtr result;
IntPtr success = ExternalMethods.SendMessageTimeout(hWnd, 0, UIntPtr.Zero, IntPtr.Zero,
SendMessageTimeoutFlags.SMTO_ABORTIFHUNG, WAIT_MILLISECONDS, out result);
if (success == IntPtr.Zero)
{
seconds += SLEEP_MILLISECONDS / 1000;
Console.WriteLine("Visual Studio is hung. {0}/{1} seconds wasted", seconds, stopWatch.Elapsed.TotalSeconds);
}
else
{
Console.WriteLine("Visual Studio is running fine.");
}
Thread.Sleep(SLEEP_MILLISECONDS);
}
}
}
}
More...
View All Our Microsoft Related Feeds