public void SaveNow()
{
if (_domForCurrentPage != null)
{
try
{
// CleanHtml already requires that we are on UI thread. But it's worth asserting here too in case that changes.
// If we weren't sure of that we would need locking for access to _tasksToDoAfterSaving and _inProcessOfSaving,
// and would need to be careful about whether any delayed tasks needed to be on the UI thread.
Debug.Assert(!_view.InvokeRequired);
_inProcessOfSaving = true;
_tasksToDoAfterSaving.Clear();
_view.CleanHtmlAndCopyToPageDom();
_bookSelection.CurrentSelection.SavePage(_domForCurrentPage);
}
finally
{
_inProcessOfSaving = false;
}
while (_tasksToDoAfterSaving.Count > 0)
{
var task = _tasksToDoAfterSaving[0];
_tasksToDoAfterSaving.RemoveAt(0);
task();
}
}
}