using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ThreadedConsumer
{
   public partial class Form1 : Form
   {
      localhost.Service svc = null;

      public Form1()
      {
         InitializeComponent();
         svc = new localhost.Service();
         svc.SlowMethodCompleted += new ThreadedConsumer.localhost.SlowMethodCompletedEventHandler(svc_SlowMethodCompleted);
      }

      void svc_SlowMethodCompleted(object sender,
         ThreadedConsumer.localhost.SlowMethodCompletedEventArgs e)
      {
         toolStripStatusLabel2.Text = "Asynchroniczna metoda zakończona.";
         MessageBox.Show(e.Result);
      }

      private void button2_Click(object sender, EventArgs e)
      {
         MessageBox.Show(svc.SlowMethod());
      }

      private void button1_Click(object sender, EventArgs e)
      {
         toolStripStatusLabel2.Text =
            "Rozpoczęto wykonywanie metody asynchronicznej...";

         svc.SlowMethodAsync();
      }
   }
}
