public override void Execute(params object[] args) { // search for keywords and find page copying = false; using (var dialog = new SearchDialog()) { if (dialog.ShowDialog(owner) != DialogResult.OK) { return; } copying = dialog.CopySelections; pageIds = dialog.SelectedPages; } // choose where to copy/move the selected pages // This needs to be done here, on this thread; I've tried to play threading tricks // to do this from the SearchDialog but could find a way to prevent hanging var desc = copying ? Resx.SearchQF_DescriptionCopy : Resx.SearchQF_DescriptionMove; using (var one = new OneNote()) { one.SelectLocation(Resx.SearchQF_Title, desc, OneNote.Scope.Sections, Callback); } }