我正在尝试运行_Main方法并在控制台中显示输出。但它没有显示输出。你能告诉我问题出在哪里吗?
{
public View_files()
{
InitializeComponent();
}
static async Task _Main()
{
List<string> fList = new List<string>();
IMongoClient client = new MongoClient("mongodb://localhost:27017/");
IMongoDatabase database = client.GetDatabase("mymongodb");
IMongoCollection<BsonDocument> collection =
database.GetCollection<BsonDocument>("store");
BsonDocument filter = new BsonDocument();
filter.Add("UserID", "abc");
using (var cursor = await collection.FindAsync(filter))
{
while (await cursor.MoveNextAsync())
{
var batch = cursor.Current;
foreach (BsonDocument document in batch)
{
Console.WriteLine(document.GetElement("FileID"));
}
Console.Read();
}
}
}
private void button1_Click(object sender, EventArgs e)
{
_Main().Wait();
}
}