private static async Task ProcessWorkItem(QueueInput <TParseResult> parseInput)
        {
            try
            {
                var result = await parseInput.ParseFile(parseInput.SourceFile);

                parseInput.TaskSource.SetResult(result);
            }
            catch (Exception e)
            {
                parseInput.TaskSource.SetException(e);
            }
        }
        /// <summary>
        /// Converts a given source file into evaluation representation.
        /// </summary>
        public Task <TParseResult> ProcessFileAsync(ISourceFile sourceFile, Func <ISourceFile, Task <TParseResult> > parseFunc)
        {
            Contract.Requires(sourceFile != null);
            Contract.Requires(parseFunc != null);

            var item = new QueueInput <TParseResult>(sourceFile, parseFunc);

            bool postResult = m_parseQueue.Post(item);

            Contract.Assert(postResult, "m_parseQueue.Post should return true.");

            // the queue handler ('ProcesWorkItem' method) completes this task
            return(item.TaskSource.Task);
        }