Ejemplo n.º 1
0
        public void LibraryBuildCompleteCallback(IAsyncResult ar)
        {
            var  buildState = (LibraryManager.BuildState)ar.AsyncState;
            bool success    = buildState.BuildFunc.EndInvoke(ar);

            if (success)
            {
                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;
                    if (!string.IsNullOrEmpty(buildState.ExtraMessage))
                    {
                        NotificationContainerForm.BeginInvoke(new Action(() => MessageDlg.Show(NotificationContainerForm, buildState.ExtraMessage)));
                    }

                    Thread th = new Thread(frm.Notify)
                    {
                        Name = "BuildLibraryNotification", IsBackground = true
                    };                                                                                             // Not L10N
                    th.SetApartmentState(ApartmentState.STA);
                    th.Start();

                    Notification = frm;
                }
            }
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        public void LibraryBuildCompleteCallback(IAsyncResult ar)
        {
            var  buildState = (LibraryManager.BuildState)ar.AsyncState;
            bool success    = buildState.BuildFunc.EndInvoke(ar);

            if (success)
            {
                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 != IrtStandard.NULL && AddIrts(buildState))
                        {
                            AddRetentionTimePredictor(buildState);
                        }
                    }));
                    var thread = BackgroundEventThreads.CreateThreadForAction(frm.Notify);
                    thread.Name         = "BuildLibraryNotification"; // Not L10N
                    thread.IsBackground = true;
                    thread.Start();
                    Notification = frm;
                }
            }
        }
Ejemplo n.º 4
0
        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();
        }
        public void LibraryBuildCompleteCallback(IAsyncResult ar)
        {
            var buildState = (LibraryManager.BuildState)ar.AsyncState;
            bool success = buildState.BuildFunc.EndInvoke(ar);

            if (success)
            {
                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;
                    if (!string.IsNullOrEmpty(buildState.ExtraMessage))
                    {
                        NotificationContainerForm.BeginInvoke(new Action(() => MessageDlg.Show(NotificationContainerForm, buildState.ExtraMessage)));
                    }

                    Thread th = new Thread(frm.Notify) { Name = "BuildLibraryNotification", IsBackground = true }; // Not L10N
                    th.SetApartmentState(ApartmentState.STA);
                    th.Start();

                    Notification = frm;
                }
            }
        }