Beispiel #1
0
 void OnValidate()
 {
     if (IsValid)
     {
         OnUpdateValues?.Invoke();
     }
 }
Beispiel #2
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            if (m_cancelOperation)
            {
                myBackgroundWorker.CancelAsync();

                while ((myBackgroundWorker.IsBusy))
                {
                    Thread.Sleep(500);
                    continue;
                }

                Thread.Sleep(500);

                OnDataFormClosing?.Invoke();

                // Remove event listeners
                MatManFunctionCollection.GetObject().OnFunctionAdded   -= functionCollection_OnFunctionAdded;
                MatManFunctionCollection.GetObject().OnFunctionRemoved -= functionCollection_OnFunctionRemoved;
                SAPRequest.GetObject().FunctionProcessedBySAP          -= sapRequest_FunctionProcessedBySAP;

                Thread.Sleep(500);

                MessageBox.Show(this, "Process has been cancelled");

                m_cancelOperation = false;

                // Clear out PWFunctionCollection completely
                MatManFunctionCollection.GetObject().Dispose();

                // Clear out SAPRequest completely
                SAPRequest.GetObject().Dispose();
            }
            else
            {
                this.uxProgressBar.Value = 100;

                this.Refresh();
                Application.DoEvents();

                Thread.Sleep(1000);

                this.uxProgressBar.Value         = 100;
                this.uxToolStripStatusLabel.Text = "Done";
                this.StatusStrip.BackColor       = Color.FromArgb(80, 161, 216);

                this.Refresh();
                Application.DoEvents();

                OnDataFormClosing?.Invoke();

                // Remove event listeners
                MatManFunctionCollection.GetObject().OnFunctionAdded   -= functionCollection_OnFunctionAdded;
                MatManFunctionCollection.GetObject().OnFunctionRemoved -= functionCollection_OnFunctionRemoved;
                SAPRequest.GetObject().FunctionProcessedBySAP          -= sapRequest_FunctionProcessedBySAP;

                // Clear out PWFunctionCollection completely
                MatManFunctionCollection.GetObject().Dispose();

                // Clear out SAPRequest completely
                SAPRequest.GetObject().Dispose();

                Thread.Sleep(2000);

                OnUpdateValues?.Invoke();
            }

            base.OnFormClosing(e);

            //FileLogger.WriteEntry(System.Reflection.MethodBase.GetCurrentMethod().Name + " " + DateTime.Now.ToString("HH:mm:ss dd-MMM-yyyy") + " -- Trace Type: Stop ")
        }