public async Task ImportAsync(Stream inputStream, PlatformExportManifest importOptions, Action <ExportImportProgressInfo> progressCallback, ICancellationToken сancellationToken) { if (importOptions == null) { throw new ArgumentNullException(nameof(importOptions)); } var progressInfo = new ExportImportProgressInfo(); progressInfo.Description = "Starting platform import..."; progressCallback(progressInfo); using (var zipArchive = new ZipArchive(inputStream, ZipArchiveMode.Read, true)) using (EventSuppressor.SupressEvents()) { //Import selected platform entries await ImportPlatformEntriesInternalAsync(zipArchive, importOptions, progressCallback, сancellationToken); //Import selected modules await ImportModulesInternalAsync(zipArchive, importOptions, progressCallback, сancellationToken); } }
public async Task NotInheritedSetAfterAsyncMethodStarts() { Assert.False(EventSuppressor.EventsSuppressed, "EventSuppressor shouldn't be active in this thread before test."); var taskCompletionSource = new TaskCompletionSource <object>(); Func <Task> notInteritedAction = async() => { await taskCompletionSource.Task; Assert.False(EventSuppressor.EventsSuppressed, "EventSuppressor shouldn't be active in this thread."); }; var checkTask = notInteritedAction(); using (EventSuppressor.SupressEvents()) { Assert.True(EventSuppressor.EventsSuppressed, "EventSuppressor inherits value in another thread!"); taskCompletionSource.TrySetResult(null); await checkTask; } Assert.False(EventSuppressor.EventsSuppressed, "EventSuppressor shouldn't be active in this thread after test."); }
private static System.Windows.Forms.ToolStrip GenerateWindowMenu(IList <WindowMenuInfo> windowMenuInfos, IList <IButton> tsbs, Dictionary <string, ToolStripItem> haveTsbs) { System.Windows.Forms.ToolStrip toolStrip2 = new System.Windows.Forms.ToolStrip(); foreach (WindowMenuInfo windowMenuInfo in windowMenuInfos) { if (windowMenuInfo.Type == WindowMenuType.Separator) { toolStrip2.Items.Add(new System.Windows.Forms.ToolStripSeparator()); } else { if (string.IsNullOrEmpty(windowMenuInfo.OriginalName)) { MyToolStripButton tsb = new MyToolStripButton(); tsb.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; if (!string.IsNullOrEmpty(windowMenuInfo.ImageName)) { tsb.Image = Feng.Windows.ImageResource.Get("Icons." + windowMenuInfo.ImageName + ".png").Reference; } if (tsb.Image == null) { tsb.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconProcess.png").Reference; } tsb.Name = "tsb" + windowMenuInfo.Name; tsb.Text = windowMenuInfo.Text; tsb.ToolTipText = windowMenuInfo.Description; tsb.Tag = windowMenuInfo; tsb.Click += new EventHandler(tsb_Click); toolStrip2.Items.Add(tsb); tsbs.Add(tsb); } else { if (haveTsbs.ContainsKey(windowMenuInfo.OriginalName)) { MyToolStripButton tsb = haveTsbs[windowMenuInfo.OriginalName] as MyToolStripButton; if (tsb == null) { continue; } tsb.DisplayStyle = ToolStripItemDisplayStyle.Image; if (!string.IsNullOrEmpty(windowMenuInfo.ImageName)) { tsb.Image = Feng.Windows.ImageResource.Get("Icons." + windowMenuInfo.ImageName + ".png").Reference; } if (tsb.Image == null) { tsb.Image = Feng.Windows.ImageResource.Get("Feng", "Icons.iconProcess.png").Reference; } tsb.Name = "tsb" + windowMenuInfo.Name; tsb.Text = windowMenuInfo.Text; tsb.ToolTipText = windowMenuInfo.Description; tsb.Tag = windowMenuInfo; EventSuppressor es = new EventSuppressor(tsb); es.Suppress(); tsb.Click += new EventHandler(tsb_Click); tsbs.Add(tsb); } else { throw new ArgumentException("There is no ToolStripItem of " + windowMenuInfo.OriginalName + "!"); } } } } return(toolStrip2); }