Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UvAsync"/> handle.
        /// </summary>
        /// <param name="loop">Loop, on which this handle will be initialized.</param>
        /// <param name="callback">A callback, which will be executed after a loop will receive an async signal from this handle.</param>
        /// <param name="state">A state object to be stored in the handle for later use inside the callback.</param>
        public UvAsync(UvLoop loop, Action <UvAsync> callback, object state = null)
            : base(loop, UvHandleType.Async)
        {
            if (callback == null)
            {
                throw new ArgumentNullException(nameof(callback));
            }

            this._Callback = callback;
            this._State    = state;
            Libuv.EnsureSuccess(Libuv.uv_async_init(loop, this, _UvAsyncCallback));
            this.NeedsToBeClosed = true;
        }