从控制台应用程序到asp.net mvc的异步等待的奇怪行为

时间:2017-02-10 00:54:37

标签: c# asp.net-mvc multithreading async-await console-application

我有以下方法,许多等待调用的方法主要是

public async Task<IEnumerable<xxxx>> LoadMessageAsync(string Name, bool isError, DateTimeOffset startTime, DateTimeOffset endTime)
    {
        return await BaseTable.yyyyyyyyyyyyyyy(typeof(xxxxxxxxxxxxx))
            .SelectManyAsync(async MessageId =>
            {
                return await Session
                    .CqlSelect<xxxxxxxxxxxxx>()
                    .Where(nameof(xxxxxxxxxxxxx.Name), Relation.Equal, Name)
                    .Where(nameof(xxxxxxxxxxxxx.MessageId), Relation.Equal, MessageId)
                    .Where(nameof(xxxxxxxxxxxxx.IsError), Relation.Equal, isError)
                    .Where(nameof(xxxxxxxxxxxxx.QueueMessageId), Relation.GreaterThanOrEqual, CqlFunctions.MaxTimeUuid(startTime))
                    .Where(nameof(xxxxxxxxxxxxx.QueueMessageId), Relation.LessThanOrEqual, CqlFunctions.MinTimeUuid(endTime))
                    .ExecuteAsync();
            });
    }

我通常从控制台调用它并返回Data。但是从asp.net MVC异步操作开始就不再返回任何想法如何解决

var result = await _dataService.LoadMessageAsync(queueName, true, _startDateTimeOffset, _endDateTimeOffset)

if (result != null && result.Any())
        {
        }

我甚至尝试过.ConfigureAwait(true);

0 个答案:

没有答案