New to the threading and its concepts. I have following code where I am using Windows.Forms in console app to print a webpage.
My Code looks like below:
My Application does print the page but it never exists . its stuck at Application.Run();
How do I make my application exit? Thanks for helping out.
( if I use Application.DoEvents(); wb.print(); does not print. )
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WebBrowserWithoutAForm
{
    class Program
    {
        private static bool completed = false;
        private static WebBrowser wb;
        [STAThread]
        static void Main(string[] args)
        {
            wb = new WebBrowser();
            wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
            wb.Navigate("http://www.google.com");
            while (!completed)
            {
                //Application.DoEvents();
                Application.Run();
            }
            Console.Write("\n\nDone with it!\n\n");
            Console.ReadLine();
        }
        static void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            Console.WriteLine(wb.Document.Body.InnerHtml);
            wb.Print();
            completed = true;
        }
    }
}
 
    