public partial class Form1 : Form { private bool stop = false; private string message; public Form1() { InitializeComponent(); icnNotify.ContextMenu = new System.Windows.Forms.ContextMenu(new System.Windows.Forms.MenuItem[] { new System.Windows.Forms.MenuItem("E&xit", new EventHandler(exit_Click)) }); System.Threading.Thread check = new System.Threading.Thread(CheckEmail); check.Start(); } private void Form1_Load(object sender, EventArgs e) { } private void exit_Click(object sender, EventArgs e) { stop = true; message = "Exiting, please wait..."; ShowMessage(); } public void CheckEmail() { //Pop3 pop3 = new Pop3("pop.gmail.com", 995, 1000); //pop3.SendCommand("USER ", false); //pop3.SendCommand("PASS ", true); //message = "Connected. Now watching..."; //Invoke(new System.Windows.Forms.MethodInvoker(ShowMessage)); //int i; //int count; //int index; //string response; //string subject; //System.IO.StreamReader input; //System.Net.HttpWebRequest request; while (!stop) { //response = pop3.SendCommand("STAT", false); System.Threading.Thread.Sleep(30000); } //pop3.SendCommand("QUIT", true); //Invoke(new System.Windows.Forms.MethodInvoker(Close)); } private void ShowMessage() { icnNotify.ShowBalloonTip(2000, "BPOs' acceptor", message, System.Windows.Forms.ToolTipIcon.Info); } } //а запуск static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); new Form1(); Application.Run(); } }