Ejemplo n.º 1
0
        // ******************************************************************
        private static void StartDlgProgress(DlgProgressModel progressModel, AutoResetEvent resetEvent, List <DlgProgress> listDlgProgressWithProgressStatus)
        {
            DlgProgress dlgProgress = new DlgProgress(progressModel);

            listDlgProgressWithProgressStatus.Add(dlgProgress);
            dlgProgress.ShowDialog();
            resetEvent.Set();
        }
Ejemplo n.º 2
0
        // ******************************************************************
        public static DlgProgress CreateProgressBar(Window owner, DlgProgressModel dlgProgressModel)
        {
            DlgProgress dlgProgressWithProgressStatus     = null;
            var         listDlgProgressWithProgressStatus = new List <DlgProgress>();
            var         resetEvent = new AutoResetEvent(false);

            IntPtr windowHandleOwner = new WindowInteropHelper(owner).Handle;

            dlgProgressModel.Owner       = owner;
            dlgProgressModel.IntPtrOwner = windowHandleOwner;

            var workerThread = new ThreadEx(() => StartDlgProgress(dlgProgressModel, resetEvent, listDlgProgressWithProgressStatus));

            workerThread.Thread.SetApartmentState(ApartmentState.STA);
            workerThread.Start();
            resetEvent.WaitOne(10000);
            if (listDlgProgressWithProgressStatus.Count > 0)
            {
                dlgProgressWithProgressStatus = listDlgProgressWithProgressStatus[0];
            }

            return(dlgProgressWithProgressStatus);
        }