CsharpDriver 2.2.3 Findasync 从不 return

CsharpDriver 2.2.3 Findasync never return

我想列出我的数据中的所有文档,并使用 Findasync (csharpdriver 2.2.3) 查找所有文档,但从未 returns。你能给我一些建议吗? 这是我的代码

public class HomeController : Controller
    {
        readonly MyVietnamContext Context = new MyVietnamContext();
        private List<UserModels> list = new List<UserModels>();
        public ActionResult Index()
        {
            GetUsers().Wait();
            return View(list);
        }

        public async Task GetUsers()
        {
            var filter = new BsonDocument();
            var collection = Context.Collection();            
            var cursor = await collection.FindAsync(filter);
            while (await cursor.MoveNextAsync())
            {
                var batch = cursor.Current;
                list.AddRange(batch);
            }            
        }
    }

将代码更改为

public async Task<ActionResult> Index()
{
   await GetUsersAsync();
   return View(list);
}

public async Task<Context.Collection> GetUsersAsync()
{
    var filter = new BsonDocument();
    var collection = Context.Collection();            
    var cursor = await collection.FindAsync(filter);
    while (await cursor.MoveNextAsync())
    {
       var batch = cursor.Current;
       list.AddRange(batch);
    }      
    return list;      
}

另请查看 Using Asynchronous Methods in ASP.NET MVC 4 页面。