0

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();
    }

}

Peter Duniho
  • 68,759
  • 7
  • 102
  • 136
  • Your question has absolutely nothing to do with MongoDB, nor with `async`/`await`. If you post another question in the future, please do a better job: search Stack Overflow for related questions; reduce your problem to a good [mcve] that reliably reproduces your problem; follow the other guidelines found at [ask], including those on that page as well as those which are found in the articles linked at the bottom of that page; and _do not_ include tags that aren't _directly_ related to the question, nor write a title that is misleading. – Peter Duniho Oct 22 '17 at 19:21
  • @PeterDuniho Is this a joke ? Why you marked this as a duplicate? –  Oct 23 '17 at 20:00
  • _"Is this a joke?"_ -- No. _"Why you marked this as a duplicate?"_ -- because it is. If you think otherwise, then edit your post to explain why you think your Winforms program is even connected to any console, never mind should you see output to one. – Peter Duniho Oct 24 '17 at 00:14

0 Answers0