public void BeginFileDownload(Uri downloadUri, long size)
        {
            lock (_Lock)
            {
                if (_FileUpdateForm == null)
                {
                    AutoResetEvent wait = new AutoResetEvent(false);

                    ThreadStart threadStart =
                        delegate
                    {
                        _FileUpdateForm = new FileUpdateForm();
                        _FileUpdateForm.DeploymentManifest = DeploymentManifest;
                        _FileUpdateForm.TotalUpdateSize    = TotalUpdateSize;
                        wait.Set();

                        Application.Run(_FileUpdateForm);
                    };
                    Thread thread = new Thread(threadStart);
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();

                    wait.WaitOne();
                }
            }
        }
Example #2
0
        private void EnsureFormWindowCreated()
        {
            lock (_Lock)
            {
                if (_FileUpdateForm == null)
                {
                    AutoResetEvent wait = new AutoResetEvent(false);

                    ThreadStart threadStart =
                        delegate
                    {
                        _FileUpdateForm = new FileUpdateForm();

                        // NOTE: Patch #2007811 - fix attached.
                        // Force creation of a handle for the form, so we can access it before it
                        // is displayed.  This fixes the exception - System.InvalidOperationException:
                        // Invoke or BeginInvoke cannot be called on a control until the window handle
                        // has been created.
                        //
                        // Thanks to DethKnite for the patch.
                        IntPtr handle = _FileUpdateForm.Handle;

                        _FileUpdateForm.DeploymentManifest = DeploymentManifest;
                        _FileUpdateForm.TotalUpdateSize    = TotalUpdateSize;

                        wait.Set();

                        Application.Run(_FileUpdateForm);
                    };
                    Thread thread = new Thread(threadStart);
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();

                    wait.WaitOne();
                }
            }
        }
        private void EnsureFormWindowCreated()
        {
            lock (_Lock)
            {
                if (_FileUpdateForm == null)
                {
                    AutoResetEvent wait = new AutoResetEvent(false);

                    ThreadStart threadStart =
                        delegate
                        {
                            _FileUpdateForm = new FileUpdateForm();

                            // NOTE: Patch #2007811 - fix attached.
                            // Force creation of a handle for the form, so we can access it before it
                            // is displayed.  This fixes the exception - System.InvalidOperationException:
                            // Invoke or BeginInvoke cannot be called on a control until the window handle
                            // has been created.
                            //
                            // Thanks to DethKnite for the patch.
                            IntPtr handle = _FileUpdateForm.Handle;

                            _FileUpdateForm.DeploymentManifest = DeploymentManifest;
                            _FileUpdateForm.TotalUpdateSize = TotalUpdateSize;

                            wait.Set();

                            Application.Run(_FileUpdateForm);
                        };
                    Thread thread = new Thread(threadStart);
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();

                    wait.WaitOne();
                }
            }
        }
        public void BeginFileDownload(Uri downloadUri, long size)
        {
            lock (_Lock)
            {
                if (_FileUpdateForm == null)
                {
                    AutoResetEvent wait = new AutoResetEvent(false);

                    ThreadStart threadStart =
                        delegate
                        {
                            _FileUpdateForm = new FileUpdateForm();
                            _FileUpdateForm.DeploymentManifest = DeploymentManifest;
                            _FileUpdateForm.TotalUpdateSize = TotalUpdateSize;
                            wait.Set();

                            Application.Run(_FileUpdateForm);
                        };
                    Thread thread = new Thread(threadStart);
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();

                    wait.WaitOne();
                }
            }
        }