/**
         * <summary>
         *   Registers the callback function that is invoked on every change of advertised value.
         * <para>
         *   The callback is invoked only during the execution of <c>ySleep</c> or <c>yHandleEvents</c>.
         *   This provides control over the time when the callback is triggered. For good responsiveness, remember to call
         *   one of these two functions periodically. To unregister a callback, pass a null pointer as argument.
         * </para>
         * <para>
         * </para>
         * </summary>
         * <param name="callback">
         *   the callback function to call, or a null pointer. The callback function should take two
         *   arguments: the function object of which the value has changed, and the character string describing
         *   the new advertised value.
         * @noreturn
         * </param>
         */
        public async Task <int> registerValueCallback(ValueCallback callback)
        {
            string val;

            if (callback != null)
            {
                await YFunction._UpdateValueCallbackList(this, true);
            }
            else
            {
                await YFunction._UpdateValueCallbackList(this, false);
            }
            _valueCallbackTemperature = callback;
            // Immediately invoke value callback with current value
            if (callback != null && await this.isOnline())
            {
                val = _advertisedValue;
                if (!(val == ""))
                {
                    await this._invokeValueCallback(val);
                }
            }
            return(0);
        }