﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace DNK.TourMLPriceSelector
{
    public class Invoker
    {
        public FormRoom InvokeFormRoom;
        private Thread InvokeThread;
        public DialogResult InvokeResult;

        public Invoker(FormRoom formRoom)
        {
            InvokeFormRoom = formRoom;
            InvokeThread = new Thread(new ThreadStart(InvokeMethod));
            InvokeThread.SetApartmentState(ApartmentState.STA);
            InvokeResult = DialogResult.None;
        }

        public DialogResult Invoke()
        {
            InvokeThread.Start();
            InvokeThread.Join();
            return InvokeResult;
        }

        private void InvokeMethod()
        {
            InvokeResult = InvokeFormRoom.ShowDialog();
        }
    }
}
