Esempio n. 1
0
        //
        // methods
        //

        /// <summary>
        /// If instance can process request execute success callback
        /// otherwise execute failure callback
        /// </summary>
        /// <param name="object">AsyncRequest</param>
        private void ProcessRequest(Object @object)
        {
            AsyncRequest request = @object as AsyncRequest;

            lock (this.dataLocker)
            {
                // If instance waits for the new data
                if (this.state == FileLinesCheckerState.Pending)
                {
                    //Wait new data
                    Monitor.Wait(this.dataLocker);
                }

                // If instance can return the answer
                if (this.state == FileLinesCheckerState.Ready)
                {
                    // Execite success callback
                    request.SuccessCallback(this.data.Contains(request.Line));
                }
                else
                {
                    // Execute failure callback
                    request.FailureCallback(this.state.ToString());
                }
            }
        }