UI hang can occur when the UI thread and a background thread are
updating the remote project builders at the same time due to two locks
being accessed in a different order.
To avoid this the RemoteBuildEngine.UnloadProject is not done
synchronously in the RemoteProjectBuilder's Dispose method.
Testing this the UnloadProject now generally seems to fail since the engine's connection has been closed before the UnloadProject is called. So not sure if this is the correct fix here.
Fixes VSTS #1030374 - [FATAL] SigTerm signal in MonoDevelop.Core.dll!
MonoDevelop.Projects.MSBuild.RemoteBuildEngine::RemoveBuilder+9
UI hang can occur when the UI thread and a background thread are updating the remote project builders at the same time due to two locks being accessed in a different order.
Background thread:
RemoteBuildEngine.GetRemoteProjectBuilder - locks remoteProjectBuilders RemoteProjectBuilder.AddReference - locks usageLock
UI thread:
RemoteProjectBuilder.Shutdown - locks usageLock RemoteProjectBuilder.Dispose RemoteBuildEngine.UnloadProject RemoteBuildEngine.RemoveBuilder - locks remoteProjectBuilders
To avoid this the RemoteBuildEngine.UnloadProject is not done synchronously in the RemoteProjectBuilder's Dispose method.
Fixes VSTS #1030374 - [FATAL] SigTerm signal in MonoDevelop.Core.dll! MonoDevelop.Projects.MSBuild.RemoteBuildEngine::RemoveBuilder+9
Backport of #9427.
/cc @slluis @mrward