Exemplo n.º 1
0
        private SubclassWindow CreateSubclassWindow(IntPtr hwnd)
        {
            var window = new SubclassWindow(this);
            var failed = false;

            try
            {
                window.AssignHandle(hwnd);
                return(window);
            }
            catch (Exception ex)
            {
                failed       = true;
                ErrorMessage = string.Format("{0}: {1}", ex.GetType().Name, ex.Message);
                throw;
            }
            finally
            {
                if (failed)
                {
                    window.ReleaseHandle();
                }
            }
        }
Exemplo n.º 2
0
        public void Detach()
        {
            IsRendering = false;
            Thread         thread = null;
            SubclassWindow window = null;

            lock (_syncRoot)
            {
                window     = _window;
                _window    = null;
                thread     = _thread;
                _thread    = null;
                _isRunning = false;
            }
            // wait&release outside lock to avoid deadlock
            if (thread != null && thread.IsAlive)
            {
                thread.Join();
            }
            if (window != null)
            {
                window.ReleaseHandle();
            }
        }