public THandle CreateAndInitializeHandle <THandle>() where THandle : Handle
        {
            this.ThrowIfDisposed();
            THandle handleToAdd = Activator.CreateInstance <THandle>();

            handleToAdd.Initialize(this);
            if (this.scope != null)
            {
                this.scope.Environment.AddHandle(handleToAdd);
                return(handleToAdd);
            }
            this.executor.AddHandle(handleToAdd);
            return(handleToAdd);
        }
        public THandle CreateAndInitializeHandle <THandle>() where THandle : Handle
        {
            ThrowIfDisposed();
            THandle value = Activator.CreateInstance <THandle>();

            value.Initialize(this);

            // If we have a scope, we need to add this new handle to the LocationEnvironment.
            if (this.scope != null)
            {
                this.scope.Environment.AddHandle(value);
            }
            // otherwise add it to the Executor.
            else
            {
                this.executor.AddHandle(value);
            }

            return(value);
        }