Waiting for a background operation to complete - visual-studio

I have been suffering from the all too common 'Waiting for a background operation to complete...' message in Visual Studio 2012 (Professional) for a while now but it has been fairly sporadic.
Lately though, I am really struggling to use Visual Studio as pretty much whenever i try and do anything with any Razor views (mostly clicking to move the cursor) visual studio hangs and the above message appears for about a minute at a time.
(If when its finished doing stuff i then click in the view again, the process repeats, and repeats, and repeats.....)
I have searched high and low, and read loads of articles regarding this and peoples suggestions and tried changing indentation settings, resetting settings, etc but none have worked.
Has anyone come across something else that may work as this is seriously impeding my ability to use visual studio and sadly provoking much cursing.

I also had the same issue with VS2012 and unfortunately I had to format my pc after trying all the following solutions:
Move/clean the symbols cache
Reset VS preferences
Install Upgrade 2
Uninstall/Reinstall VS
After formatting and reinstalling VS2012, it started working like a charm again (obviously).
Sorry for that.

I know I asked this question a while back, but I thought best to put up my findings as they may help others.
The exact reason for the Waiting dialog is still unknown, but I have since moved my project to a local disk and implemented Team Foundation server to perform the hosting and backup of the main project files.
Since moving to local disk and using TFS, I have not experienced any more of the VS Waiting dialog.

Check if IIS or another process (BizTalk maybe) is locking your DLLs/references
Kill/stop IIS if it is

Related

How do i get Visual Studio 2015 to highlight brackets, braces and references instantly, with no delay?

When placing the curser on a closing bracket in c# for instance, there is a small annoying delay before the opening bracket gets highlighted, and you have to sit and wait before you can use shortcuts such as (ctrl + shift + up/down). It feels like it is intended behaviour for reasons beyond me, so i don't think it is a bug or because my computer is slow (it's not), but it's driving me crazy.
I'm on a freshly installed PC, so i have only testet it in a few programming languages / file formats, and the behaviour only occours in some of them.
The delayed highligh behaviour occurs in .cs (c#), and .css files, but not in .js and .html files, here the code gets highlighed instantaneously exactly like i want it to in .cs files aswell.
I'm using Visual Studio 2015 Community Edition.
I have had this problem as well, since first installing. I can confirm that Update 1 CTP addresses this issue, and the delay is almost gone (maybe 1/8 second now.)
This UI delay was actually called out as a bugfix that was included with the update:
https://support.microsoft.com/en-us/kb/3025135
To the problem that there is a delay highlighting the brackets: In my opinion that has nothing to do with a bug. I think it takes a little while because your code needs to be parsed every time you change something in order to highlight the brackets. When you have many lines of code in one file it is obvious that it takes a little more time than normal.
Here are some tips that may help you:
Click the bracket and press STRG + ´ this will bring you directly to the other bracket. Or you press ALT + ´ and it will mark all your code in between your current brackets. You can look up the shortcuts of Visual Studio in Tools -> Options -> Environment -> Keyboard:
I'd recommend everybody programming in Visual Studio is to change the highlight color of the matching bracket. Have a look at this:
Here you can change all the colors and forms used for specific searchterms. I personally use Visual Assist 2015 to highlight my code (that's why I didn't change anything here). It is way more faster than VS itself and comes with a lot more functions like bracket guidelines who will show you the indent level of your brackets. Have a look, maybe you like it:
Its about 500ms in a newly created console project
500 msec is a magic number in .NET. You can get some insight from the source code for the C# Language Service, accidentally (?) exposed by a Microsoft programmer on github. Most relevant file is probably this one:
internal interface IBraceMatchingService
{
Task<BraceMatchingResult?> GetMatchingBracesAsync(Document document,
int position, CancellationToken cancellationToken = default(CancellationToken));
}
Or in other words, the brace matching service runs as a background task. Such tasks normally run on a thread-pool thread and are subject to scheduling by the threadpool manager. That's where the magic 500 ms number comes into play. The manager attempts to keep the number of executing tp threads down to the number of processor cores available on the machine, the most efficient way to run threads. However, if the existing tp threads take too long to finish their job then the manager assumes that they are bogged down by I/O and allows an extra one to run. It does this once every 500 msec.
So first-order estimate of your problem is that VS has too many active thread-pool threads and they don't complete in a timely manner. Causing the brace matching task to run too late.
Finding out exactly what specific tasks bog it down is technically possible. I can't guarantee success with the Community edition and you'd need a fair amount of insight in how to read thread call stacks to get ahead. Startup another instance of Visual Studio and use Debug > Attach to Process. Pick "devenv.exe" from the list. Let it trundle while it is attempting to find PDB files, then use Debug > Break All.
First place to look is Debug > Windows > Tasks. Pretty unlikely you'll see anything there however, normal is to see none. Next one is Debug > Windows > Threads. You ought to see about 15 active threads back in that window. Hover over their Location column to take a peek at their callstack. Making sense of what you see isn't that simple unfortunately, it will help a lot if you can compare what you see with another machine that does not have this problem.
Since you have this problem on more than one machine, another approach is to look for an environmental factor that they have in common. Things to look for are aggressive anti-malware, a network connection that is too slow or too unreliable, a poorly performing add-in that you like but runs poorly on a VS version it wasn't tested on.
And consider that VS2015 isn't exactly ready for prime-time. Of all the recent VS versions released in the past 18 years, it is probably the least stable. It has a lot of heavy internal changes and there were an unprecedented number of alpha and beta versions with critical bug fixes implemented just a few months ago. Try it again after Update 1 is released.
Seems like this will be fixed in a future Visual Studio update: https://github.com/dotnet/roslyn/issues/1906#issuecomment-145874647
I have not found a definitive solution for your problem.
This was a known bug in the VS2015 review edition.
This links discusses the delay (this link refers to c# btw, not c):
https://connect.microsoft.com/VisualStudio/feedback/details/1033540/braces-are-not-highlighted-correctly-in-c
And there are still similar problems for some VS2015 Community Edition users.
http://www.developerteacher.com/msdn/bracket-matching-highlights-not-working-like-i-had-in-2013-express-4227
Personally, I think you are stuck with a bug and if I were you I'd try the following:
Make sure I had unistalled all previous editions of VS.
Try a repair.
Completely uninstall and reinstall VS2015 if running repair doesn't work
Go back to VS2013 if it drives you cannot stand it, and wait until VS2015 is a bit more ripe on the vine.
One thing I have found with VS, is when it plays up it's painful, it takes so long to install and the worst case was when I ended up uninstalling and downloading everything that was associated with the install. It now works fine. (this was after previewing 2015 and then going back to 2013). You can also try this for VS2015 and also try a new download.
I sometimes will have a look at some previews, but after jumping in with haste too many times with the latest software releases and then repenting with leisure. I am now happy to wait for new releases to be out for a while before upgrading.
Another FYI for you to browse.
This is a link to Visual Studio 2015 RC fixed bugs and known issues. There are quite a few issues and hacks suggested. (not specific to your problem, but still there a few months ago.).
I am assuming you know how to play around with the settings. I've added the obvious, in case it's been overlooked.
I have added this screen shot from VS2013 settings.
Make sure you have automatic delimeter highlighting checked.
Sorry I could not be of more help.

How to overcome the lagging of typing in the editor while using ReSharper?

I'm using Visual Studio 2013 with ReSharper 9 on a quite strong computer (16GB RAM, Core i7 CPU, SSD, etc.). Still I experience heavy delays and laggings during typing for example in a C# or Razor source file.
I've noticed that every time I hit a key, the processing immediately starts, and context actions, offering rename refactorings, autocompetion immediatley shows up in the editor. It would make sense to delay these stuff for example so that all of this processing would start only when I finish typing and have some amount of quite milliseconds.
I've browsed through the settings for the third time now, but could not find anything related. Is there anything like this? If yes, where? If no, what else could I do to overcome this lagging? It's really annoying and I don't quite understand it. I can't beleive that such a computer is still not enough.
Disable Bing Developer Assistant extension if you have it by going to 'Tools -> Extension And Updates'.
Disable the Microsoft Git Provider Plugin by going to 'Tools -> Source Control -> Then setting the Plug-In ComboBox to NONE.'
The above has helped me and has improved performance on my PC. Hopefully it will help you too.
You shouldn't be seeing a lag while typing. I'd suggest disabling other extensions to see if there's a clash - something that ReSharper doesn't like being installed at the same time. Alternatively (or better yet, as well) you can profile Visual Studio to see what's going wrong. Go to ReSharper → Help → Profile Visual Studio, and ReSharper will download the profiler, attach to Visual Studio and start to gather info. Once you've demonstrated the problem, click "Get snapshot", and ReSharper will save the snapshot and add it to the dialog as an attachment. You can then describe what you were doing and submit the snapshot and description to the dev team.
I'd also suggest downloading the latest build - the 9.2 EAP has just started, and contains a number of fixes that might help performance under certain circumstances.
Also, what are you typing in - what language, what size file?

Browser Link always asking for "Do you want to stop debugging"

Just wondering my browser keeps asking if I want to stop debugging every time I hit browser link refresh very annoying as is slowing down devtime.
Has anybody else come across this?
cheers
Updated Answer, Root Cause Now Found
After what is now TWO years of seeing this error on and off I finally understand what's causing this. A BIG Thank you goes out to Damian Edwards for mentioning this in a community stand-up!
As a developer, we often do all of our development in Visual Studio in Debug mode rather than release mode. And it's very common for us to run our projects with F5. In this case VS runs the project with the debugger enabled, no surprise there.
So it turns out, the "Do you want to stop debugging? error dialog when you try to refresh via browserlink is saying is "Hey you made some changes that look like they might require recompiling the razor view in order to refresh the page, and in order to do that Visual Studio needs to stop the debugger session, is that OK?"
And the fix? This is gonna blow your mind. When you want to use browser link to rapidly refresh the page while doing html/css changes and never see this message again, do this: run the project using CTL+F5 instead of F5. This will run the project without firing up the debugger and you probably weren't gonna use the debugger anyway if you were planning on doing a bunch of html css work on a view using browerlink. :-) That's it, no more error message. Bam. You're welcome. (It took me T W O Y E A R S to figure that out. Hand against forehead, eyes rolling)
I have left my original answer below because it did seem to help in some cases and it has already received a couple upvotes, but in hind sight, I think it was more of a coincidental observation than a root cause..
Original
I have been struggling with this issue for nearly a year. I may have just discovered the cause. I was running two copies of visual studio, each with different web projects, at the same time. Then when I try to get browserlink to refresh the browser in one copy of visual studio it asks “Do you want to stop debugging”.
I then quit out of the 2nd copy of visual studio, and re-ran the web project in the first copy of visual studio and when I tried to get browserlink to refresh the browser it worked fine with no prompt. Yea. A better error message than “Do you want to stop debugging” might have been "It looks like you are running two web projects at the same time in different copies of visual studio. Browserlink does no support this, please close one of them."
You may want to check out this post: https://stackoverflow.com/a/21706524/4079626. If you are using an older version of IE (like IE9), then long-polling may be the issue.
Short answer
Browser Link will only use WebSockets on Windows 8 or Windows Server
2012
Longer answer
The following would explain the issue if you're using Visual Studio on
Windows 7, Windows Vista or Windows Server 2008:
IIS (Express) depends on the .NET framework implementation in
System.Net.WebSockets to handle WebSocket connections; as you
can read in the link to MSDN, you simply don't get an actual
implementation of the necessary classes when you install .NET 4.5 on
Windows 7.
So in that case, the server can't agree to the client's request to
change from standard HTTP to the WebSocket protocol, which forces the
SignalR client to use one of the fallback options (in your case:
long-polling).

ASP.NET MVC3 Razor views - extremely slow editing in VS2010

I've got a relatively small project written in ASP.NET MVC3. After working a while, Visual Studio 2010 becomes very slow in Razor views (other file types work fine). With "slow" I mean "every keystroke takes around 1 second to register". It doesn't matter what that keystroke was - typing a single letter is as slow as pasting a screenful of markup. During this slowdown VS2010 consumes 1 CPU core to 100%. After I restart VS2010, everything goes smoothly again for a small while. This happens in any and all Razor views.
My PC isn't the best, but it should be enough: Core 2 Duo 6700, 4GB of RAM (currently only 75% filled with VS2010 being slow and all, so it's not a RAM shortage), Windows 7 x64.
The project is close to an end, and I remember that for most time there were no problems. This has started only recently, although I cannot imagine what could have caused it.
Does anyone have any ideas about what could be wrong and what could be done to fix it?
It is plugins - TFS/AnkvSVN and ReSharper have all caused problems for me.
Turn them off one by one, to discern which one (if only one) is causing you grief.
When you find the culprit, make sure you keep up on any patches with it.
In extreme cases, turn if off if you have a long development session and don't need it the whole time (SVN for instance could be turned on when you are ready to do commits and check ins, etc.)
The issue is resolved for me, by installing the Mvc Html5 Templates.
After the installation, I picked XHTML5 and then back HTML5 from the "Target schema" combo box. After that, the paste was instant!
Edit: I uninstalled "Mvc Html5 Templates" and the issue didn't reappear. Perhaps it has something to do with the "HTML 5 Intellisense"
Have you installed sp 1 it fixed some performance related issues when loading IntelliSense for markup
Run the Resource Monitor (CTRL+SHIFT+ESC, click Performance tab then Resource Monitor button at the bottom). Pay special attention to disk I/O and perhaps CPU usage.
Sort disk I/O by Total B/Sec descending. As you type, see if it can identify a process which is causing the issue. Hopefully it's a virus scanner or some other famous performance destroyer and not the Visual Studio process itself, which wouldn't be very helpful.
Have you tried opening the same project on a different machine? This will give you an idea whether issue is in the project or VS install. Quite obvious, but is there anything in the event viewer. Are you connected to a domain while this is happening?
Well, for me the problem has turned out to be anti virus - we use (or are made to suffer) Sunbelt Vipre on our workstations and as soon as I switch off active protection (so that's basically disabling AV completely) all of a sudden all the performance issues in all windows are gone.
Sorry for adding another answer, but there seem to be lots of different causes, so - lets list all possible fixes here.
I tried disabling ReSharper and other addons - did not work. What did work - is reapplying the SP1 again.
PS. Weird, I know. Don't ask, no idea... My guess is - VS was "repairing" itself silently at some point and restored some non-SP1 components.
PPS. You might also want to try disabling "Productivity Power Tools" addon. If you have ReSharper installed - almost all the PPT features are already there, in ReSharper.
PPPS. I have a blog post with several performance tips for Visual Studio & ReSharper, might come handy..
Have you tried Cleaning the solution?
In my case, high CPU usage started out of nowhere (WPF project). Restarts of Visual Studio didn't help, neither disabling/uninstalling addons. But Cleaning the solution did help!
I was experiencing a very similar issue on a large cshtml file in VS 2015 and was solved for me by turning off all of the automatic formatting options in Options > Text Editor > C# > Formatting > General:
I then use the "Control+K,D" key combination to format the page once I have finished making the necessary code changes.

Visual Studio 2005 - Projects disappearing

Hmmm, a new odd issue that has just started. Every now and then VS drops a whole bunch of projects from the solution. It will say at the top of Solution explorer "42 projects" when it is displaying only about 20 or so. Closing VS and re-opening it fixes this, although it is a bit of a pain as it takes a little while for the .sln to open again.
We run VS2005 and mainly work on a 42 project solution targetting the Compact Framework 2.00. I'm pretty much the only one using Resharper here (despite my recommendations to others and their occasional oOoing and ahhing at its beauty) so i use CTRL+T to find classes but when i've been hitting SHFT + ALT + L to select the item in the solution explorer (to view the history in TFS) it hasn't matched anything which is how i've noticed this issue.
Anyone experienced this before?
Though this doesn't address your problem directly, have you considered breaking it up into multiple solutions? I'd imagine VS chokes when it starts to get that large, and you're probably working in an un-tested (though not un-supported, I suppose) situation, since I doubt the MS testers created a solution holding 40 projects, all targeting CF.NET.
If you can break it up, that's what I'd advise, and I'll bet the problem goes away. Also, have you tried installing the Service Pack for VS? If not, here it is.
Well this question is super old now and according to my old self:
I think I just rebooted or something and I haven't seen the issue again.
This seems to be about as close as we'll ever get to a solution so I'll set this as the accepted answer for now.

Resources