private void Editor_DragDrop(object sender, DragEventArgs e) { int row = 0; if (ContainerControl.PerformDrop(e, out row)) { return; } FileDragInfo info = e.Data.GetData(typeof(FileDragInfo)) as FileDragInfo; if (info != null && info.DraggedItems != null) { if (info.DraggedItems.Count > 1 || info.DraggedItems[0].NodeType == DraggedItemType.Directory) { System.Threading.CancellationTokenSource tokenSource = new System.Threading.CancellationTokenSource(); TaskProgressMonitor monitor = new TaskProgressMonitor(this, StringResources.AddingFiles, tokenSource); monitor.IncreaseProgress(0.1, StringResources.GettingTitles); var task = DragAndDrop.GetElementsFromDroppedItemsAsync(info, tokenSource.Token, monitor); task.ContinueWith((t) => { monitor.Close(); try { var result = task.Result; if (result != null) { ContainerControl.AddElements(result, row); } } catch (AggregateException) { } }, tokenSource.Token, System.Threading.Tasks.TaskContinuationOptions.OnlyOnRanToCompletion, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext()); task.ContinueWith((t) => { monitor.Close(); }, tokenSource.Token, System.Threading.Tasks.TaskContinuationOptions.NotOnRanToCompletion, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext()); } else { List <Ares.Data.IElement> elements = new List <Ares.Data.IElement>(DragAndDrop.GetElementsFromDroppedItems(info)); ContainerControl.AddElements(elements, row); } } }