/// <summary>
        /// Updates the content of the project file to be the latest msbuild text.
        /// </summary>
        /// <returns></returns>
        private async Task UpdateProjectFileAsync()
        {
            // We do this on the UI thread to ensure that between setting the state to a variant of ProjectFileChanging and setting the window
            // frame to readonly, the user can't do any input (and potentially cause a conflict).
            await _threadingService.SwitchToUIThread();

            lock (_lock)
            {
                // Only update the project file if we have scheduled an update. Any other state is either already updating the buffer,
                // or in the processes of closing the buffer.
                if (_currentState != EditorState.BufferUpdateScheduled)
                {
                    return;
                }
            }

            // Set set the buffer to be unmodifiable to prevent any changes while we update the project
            await _textBufferManager.SetReadOnlyAsync(true).ConfigureAwait(true);

            // Set the buffer to default state and set the current state to editor clean
            await _textBufferManager.ResetBufferAsync().ConfigureAwait(true);

            lock (_lock)
            {
                _currentState = EditorState.EditorOpen;
            }
            await _textBufferManager.SetReadOnlyAsync(false).ConfigureAwait(true);
        }