Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are button clicks slow in VS 11, and how to fix it?

Here is a simple test application (in F#, but I checked and the same problem occurs in C#):

let but = new Button(Content = "click me")
but.Click.Add(fun e -> printfn "clicked")
[<STAThread>]
do (new Application()).Run(new Window(Content = but))

When running this in VS 11 preview (no matter which .NET version), the "clicked" message appears ~0.5 seconds after clicking. The same happens in C#. When I go to the folder where the project is stored and run the .exe outside of VS then the message appears instantly after clicking. Apparently the debugging instrumentation is slowing this particular case down tremendously. Why is this and what can be done about it?

like image 681
Jules Avatar asked Nov 18 '11 01:11

Jules


2 Answers

I cant say for sure, but my past experience with developer previews is that they have monitoring and tracing code that is running and submitting feedback to microsoft. This has caused slowdowns for me before in other previews (cant remember if button clicks were affected). You might submit feedback to microsoft though to ensure they know about it.

like image 123
Nikkoli Avatar answered Sep 28 '22 14:09

Nikkoli


Or... I don't have VS v.11, but similar bug happeneds in VS 2010.

Go to: Debug->Options and Settings->Debug->General, select: "Break when exceptions cross AppDomain...".

If debugger stops now on these exceptions, it means, that the old bug is not fixed. It's Visual Studio bug, so everything works fine when running .exe.

like image 33
Maciek Świszczowski Avatar answered Sep 28 '22 15:09

Maciek Świszczowski