public void LibraryBuildCompleteCallback(LibraryManager.BuildState buildState, bool success) { // Completion needs to happen on a separate thread because of the access to UI elements // In order to make sure the thread handle is released, it needs to call Application.ThreadExit() var threadComplete = BackgroundEventThreads.CreateThreadForAction(() => { if (success && NotificationContainerForm.IsHandleCreated) { // Only one form showing at a time lock (this) { RemoveLibraryBuildNotification(); var frm = new BuildLibraryNotification(buildState.LibrarySpec.Name); frm.Activated += notification_Activated; frm.Shown += notification_Shown; frm.ExploreLibrary += notification_ExploreLibrary; frm.NotificationComplete += notification_NotificationComplete; Point anchor = NotificationAnchor; frm.Left = anchor.X; frm.Top = anchor.Y - frm.Height; NotificationContainerForm.BeginInvoke(new Action(() => { if (!string.IsNullOrEmpty(buildState.ExtraMessage)) { MessageDlg.Show(TopMostApplicationForm, buildState.ExtraMessage); } if (buildState.IrtStandard != null && !buildState.IrtStandard.Name.Equals(IrtStandard.EMPTY.Name) && AddIrts(buildState)) { AddRetentionTimePredictor(buildState); } })); frm.Start(); Assume.IsNull(Interlocked.Exchange(ref _notification, frm)); } } }); threadComplete.Name = @"Library Build Completion"; threadComplete.Start(); }
public void LibraryBuildCompleteCallback(LibraryManager.BuildState buildState, bool success) { // Completion needs to happen on a separate thread because of the access to UI elements // In order to make sure the thread handle is released, it needs to call Application.ThreadExit() var threadComplete = BackgroundEventThreads.CreateThreadForAction(() => { if (success && NotificationContainerForm.IsHandleCreated) { // Only one form showing at a time lock (this) { RemoveLibraryBuildNotification(); var frm = new BuildLibraryNotification(buildState.LibrarySpec.Name); frm.Activated += notification_Activated; frm.Shown += notification_Shown; frm.ExploreLibrary += notification_ExploreLibrary; frm.NotificationComplete += notification_NotificationComplete; Point anchor = NotificationAnchor; frm.Left = anchor.X; frm.Top = anchor.Y - frm.Height; NotificationContainerForm.BeginInvoke(new Action(() => { if (!string.IsNullOrEmpty(buildState.ExtraMessage)) { MessageDlg.Show(TopMostApplicationForm, buildState.ExtraMessage); } if (buildState.IrtStandard != null && !buildState.IrtStandard.Name.Equals(IrtStandard.EMPTY.Name)) { // Load library Library lib = null; using (var longWait = new LongWaitDlg { Text = Resources.LibraryBuildNotificationHandler_AddIrts_Loading_library }) { var status = longWait.PerformWork(TopMostApplicationForm, 800, monitor => { lib = NotificationContainer.LibraryManager.TryGetLibrary(buildState.LibrarySpec) ?? NotificationContainer.LibraryManager.LoadLibrary(buildState.LibrarySpec, () => new DefaultFileLoadMonitor(monitor)); foreach (var stream in lib.ReadStreams) { stream.CloseStream(); } }); if (status.IsCanceled) { lib = null; } if (status.IsError) { throw status.ErrorException; } } // Add iRTs to library if (AddIrts(lib, buildState.LibrarySpec, buildState.IrtStandard, NotificationContainerForm, true)) { AddRetentionTimePredictor(buildState); } } })); frm.Start(); Assume.IsNull(Interlocked.Exchange(ref _notification, frm)); } } }); threadComplete.Name = @"Library Build Completion"; threadComplete.Start(); }