internal int RegisterCommandInternal(string command, string description, FCVar flags, CommandExecuteDelegate callback)
        {
            ManagedCommand cmd = this.CreateCommand(command, description, flags, callback);

            byte[] cmdUTF8  = this.m_enc.GetBytes(command);
            byte[] descUTF8 = this.m_enc.GetBytes(description);
            int    iFlags   = (int)flags;

            int id = this.RegisterCommandImpl(cmdUTF8, descUTF8, iFlags, cmd.Id);

            if (id == -1)
            {
                this.UnregisterCommandDic(id);
            }
            return(id);
        }
        public Task <int> RegisterCommand(string command, string description, FCVar flags, CommandExecuteDelegate callback)
        {
            ManagedCommand cmd = this.CreateCommand(command, description, flags, callback);

            byte[] cmdUTF8  = this.m_enc.GetBytes(command);
            byte[] descUTF8 = this.m_enc.GetBytes(description);
            int    iFlags   = (int)flags;

            return(this.m_fact.StartNew(() =>
            {
                int id = this.RegisterCommandImpl(cmdUTF8, descUTF8, iFlags, cmd.Id);
                if (id == -1)
                {
                    this.UnregisterCommandDic(id);
                }
                return id;
            }));
        }
        protected ManagedCommand CreateCommand(string name, string description, FCVar flags, CommandExecuteDelegate callback)
        {
            int            id  = Interlocked.Increment(ref s_commandId);
            ManagedCommand cmd = new ManagedCommand
            {
                Id          = id,
                Name        = name,
                Description = description,
                Flags       = flags,
                Callback    = callback,
            };

            lock (this.m_commands)
            {
                this.m_commands.Add(cmd.Id, cmd);
            }
            return(cmd);
        }