I am trying to run the _Main method and display the output in the console.But it is not showing the output. Can u tell me where is the problem?
{
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();
}
}