What is this 'Waiting for Background operation

2019-01-08 05:47发布

问题:

Occassionaly, but fairly often, for no apparent reason, VS 2012 will lock up with a dialogue that says, "Waiting for a background operation to finish". E.g. this may happen during a plain old code edit, not on explicitly invoking any IDE command.

What causes this, and is there anything I can do about this?

I am running ReSharper 7, and I am not the only one I know experiencing this.

回答1:

I was having the same problem, especially in cshtml pages. I found this page: http://blogs.msdn.com/b/webdev/archive/2012/03/06/visual-studio-11-beta-razor-editor-issue-workaround.aspx that suggests changing the indent option in Tools > Options > Text Editor > HTML > Tab to Smart instead of Block. In my case it was already set to Smart and changing it back to Block fixed the problem.

Update: I was wrong, that didn't fix the dialogue, it just delayed it until I copied or pasted. What finally worked for me was to go to Tools > Import and Export Settings... > Reset all settings.

Possibly related question: Visual Studios 2010 - Asp.net MVC 4 Beta - long delays on paste and frequent crashing



回答2:

It is a very generic diagnostic. It is triggered by COM, heavily used in Visual Studio to implement extensibility. The underlying trigger is the IMessageFilter interface. The trigger occurs when COM marshals a method call to another thread and that call doesn't complete for 60 seconds.

There's little value in the actual notification, it is telling you something you already know. By the time 60 seconds have passed, you typically already have noticed things are not working well. Short from the wee bit of useful knowledge that Visual Studio isn't actually completely dead. The call however has to complete before VS gets usable again. There's little you can do but tap your foot and wait.

This problem is almost always caused by an add-in. Resharper is certainly a good candidate. You find the trouble-maker by disabling the add-ins one-by-one until the problem disappears. It is the kind of problem that's common with new versions of Visual Studio, it takes the add-in vendors a while to get the bugs and hangups ironed out. Contact the vendor for support and in general look for updates that may solve the issue.



回答3:

I was having the same problem and in my case it was DevExpress.

It seemed to hang Visual Studio everytime I did a copy or cut operation, bringing up the message:

"Waiting for a background operation to finish".

Turns out it was actually doing a one off task in the background and it really was taking a while to do it (over 5 minutes).

Perhaps if I had waited normally, it could have gone away, but what finally fixed it was to bring up the Toolbox into view (was hidden/collapsed), which in turn brought up a window saying:

"adding [SomeDevExpressAssemblyNameHere].dll"

this kept updating itself with the name of every dll required by DevExpress to populate the toolbar.

This way I could see the operation progress and after it finished I could use copy/cut paste again as usual.

Hope this helps.



回答4:

Deleting the Solutions "suo" file worked for me.



回答5:

For me the fix was to update the Web Essentials 2012 to version 1.8.

The problematic version was 1.6



回答6:

Tools > Options > Text Editor > HTML > Tabs -> Identing -> None settings solved this problem for me.



回答7:

This fixed it for me:

Tools > Options > Text Editor > HTML > Miscellaneous

Uncheck the option "Auto ID elements on paste in Source View"

I will post an update if the problem comes back.



回答8:

I had this problem for a couple of days, tried uninstalling and reinstalling my visual studio 2012 ultimate edtion SP3... Still didn't work. So I deleted all my extensions (git tools for VS 2012 and Nuget Package downloader), restarted my VS and it worked liked a charm again! Hope it works !

Good luck!



回答9:

http://geekswithblogs.net/sevenfortytwo/archive/2006/11/23/97947.aspx

RUN> issreset , now it is working fine for me in vs2012....



回答10:

I experienced this problem while running visual studio in a virtual machine - Virtual Box 4.2 running on Mac OS X Mountain Lion, hosting a fresh Windows 7 install with nothing else installed but Visual Studio. I found that the problem was caused by 2 separate issues.

Firstly, my project was on a folder shared from the host OS. In other words, on the Windows Guest, my project appeared on a network drive. So opening the project in Visual Studio from a network drive seemed to cause this problem because the problem went away when I copied the project onto the C drive of the Windows VM and opened it in Visual Studio from the copy on the C drive.

Secondly, I began to experience the problem again when the hard drive on the virtual machine was getting full. I had about 1GB free space available on the hard drive. When I increased the size of the hard drive on the virtual machine, this issue went away.



回答11:

Just reproduced similar problem with Codemaid add-on. Found this conversation:

There's a lot of details in this issue, but to try and recap the issue is that the VS2012 C++ API introduced a deadlock issue when the API is accessed from a UI thread (e.g. a WPF context like Spade). It wasn't an issue in VS2010, and Microsoft has fixed it going forwards for VS2013 but they will not be patching it for VS2012.

Seems to indicate that a fix (for Codemaid) should be coming:

Please keep an eye on this thread for the ongoing resolution of the issue. It ties in to that larger rewrite so I've been building towards it by adding a lot of unit tests first to help ensure functionality remains consistent after the changes.



回答12:

For me it seemed to be related with the razor syntax, since I only had it on one particular file.

For example if I put the following code in one line I had the described issue.

@section BodyClassName {note}

But when putting the closing parenthesis on the next line the issue went away

@section BodyClassName {note
}

Kind regards

Stijn



回答13:

Far from an ideal solution, but please trying running visual studio in administrator mode i tried virtually everything, and this was the only thing that worked for me



回答14:

Open Visual Studio, create a new MVC application, close the new application, open the old application and it works!



回答15:

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



回答16:

i think i have found a clue! Every thing is ended to dcomcnfg.exe!

Open it and go under following path:

Component services>computers>my computer>dcom config

after click on dcom you'll see many warnings depend on amount of components on your pc.

Click yes on each message box in order to add correct record for dcom.



回答17:

I found that VS also loads packages during the "background operation". You can remove unneeded extensions to make the operation faster.



回答18:

I have it fixed weeks ago after I turn TeamViewer 8 Clipboard Sync off! now it appears back with no reason so I tried reset all settings and it worked for me.



回答19:

I was having the same problem and running VS as an administrator seems to have done the trick for me (I had posted a similar question at Visual Studio 2012 Express Hangs with Message "Waiting for Background Operation to Complete" on Format Document Command that was marked as a duplicate for this one so I figured I would share here as well).



回答20:

For me, it was Resharper addon opening a dialog which didn't show. I only found the dialog icon in the hidden icons menu on the task bar. When i got rid of the dialog, Visual Studio returned to normal immediately.