Esempio n. 1
0
    public static void Main()
    {
        Thread t = new Thread(ThreadProc);

        Console.WriteLine("Before setting apartment state: {0}",
                          t.GetApartmentState());

        t.SetApartmentState(ApartmentState.STA);
        Console.WriteLine("After setting apartment state: {0}",
                          t.GetApartmentState());

        bool result = t.TrySetApartmentState(ApartmentState.MTA);

        Console.WriteLine("Try to change state: {0}", result);

        t.Start();

        Thread.Sleep(500);

        try
        {
            t.TrySetApartmentState(ApartmentState.STA);
        }
        catch (ThreadStateException)
        {
            Console.WriteLine("ThreadStateException occurs " +
                              "if apartment state is set after starting thread.");
        }

        t.Join();
    }
Esempio n. 2
0
        public void TestTrySetApartmentState()
        {
            Thread t1 = new Thread(new ThreadStart(Start));

            t1.SetApartmentState(ApartmentState.STA);
            Assert.AreEqual(ApartmentState.STA, t1.ApartmentState, "#1");

            bool result = t1.TrySetApartmentState(ApartmentState.MTA);

            Assert.IsFalse(result, "#2");

            result = t1.TrySetApartmentState(ApartmentState.STA);
            Assert.IsTrue(result, "#3");
        }
Esempio n. 3
0
        public TaskQueue(ThreadPriority priority, string threadName, bool isStaThread)
        {
            _semaphore                   = new SemaphoreSlim(1);
            _workEventWaitHandle         = new AutoResetEvent(false);
            _readyEventWaitHandle        = new AutoResetEvent(true);
            _finishedEventWaitHandle     = new AutoResetEvent(false);
            _workAvaiableEventWaitHandle = new AutoResetEvent(false);
            _workToBeDone                = new Queue <Action>();

            _working = true;

            _workingThread  = new Thread(WorkingMethod);
            _executorThread = new Thread(AsyncExecutor);

            if (isStaThread)
            {
                _workingThread.TrySetApartmentState(ApartmentState.STA);
                _executorThread.TrySetApartmentState(ApartmentState.STA);
            }
            else
            {
                _workingThread.TrySetApartmentState(ApartmentState.MTA);
                _executorThread.TrySetApartmentState(ApartmentState.MTA);
            }

            if (threadName != null)
            {
                _workingThread.Name  = $"{threadName} Worker";
                _executorThread.Name = $"{threadName} Executor";
            }


            try
            {
                _workingThread.Priority = priority;
                _workingThread.Start();
                _executorThread.Start();
            }
            catch (ThreadStateException)
            {
                //_log.Error($"Konnte den Aufgaben Thread nicht starten: {e.Message}");
            }
            catch (OutOfMemoryException)
            {
                //_log.Error("Konnte den Aufgaben Thread nicht starten, da zu wenig Arbeitsspeicher vorhanden ist");
            }
            TaskQueues.Add(this);
        }
 //Remover quarto
 private void btnremoverqrt_Click(object sender, EventArgs e)
 {
     this.Close();
     f2 = new Thread(remover_Quarto);
     f2.TrySetApartmentState(ApartmentState.STA);
     f2.Start();
 }
Esempio n. 5
0
        /// <summary>
        ///     Init all modules
        /// </summary>
        private void Init()
        {
            _isRun = true;

            Height = SystemParameters.PrimaryScreenHeight * 96.0 /
                     (int)Registry.GetValue("HKEY_CURRENT_USER\\Control Panel\\Desktop", "LogPixels", 96);
            Width = SystemParameters.PrimaryScreenWidth * 96.0 /
                    (int)Registry.GetValue("HKEY_CURRENT_USER\\Control Panel\\Desktop", "LogPixels", 96);

            Visualizer.Height = Height;
            Visualizer.Width  = Width;

            _wasapiLoopbackCapture = new WasapiLoopbackCapture();
            _wasapiLoopbackCapture.DataAvailable += _wasapiLoopbackCapture_DataAvailable;

            _waveIn = new WaveIn
            {
                WaveFormat         = _wasapiLoopbackCapture.WaveFormat,
                BufferMilliseconds = (int)(Audio.BufferSize / (double)Audio.Rate * 1000.0)
            };
            _waveIn.DataAvailable += _waveIn_DataAvailable;

            _bufferedWaveProvider = new BufferedWaveProvider(_wasapiLoopbackCapture.WaveFormat)
            {
                BufferLength            = Audio.BufferSize * 2,
                DiscardOnBufferOverflow = true
            };

            _updateThread = new Thread(Update);
            _updateThread.TrySetApartmentState(ApartmentState.STA);
            _updateThread.Start();
        }
 private void Btn_exit_Click(object sender, EventArgs e)
 {
     this.Close();
     th = new Thread(Opennewform);
     th.TrySetApartmentState(ApartmentState.STA);
     th.Start();
 }
Esempio n. 7
0
 //Adicionar cliente
 private void btnadicionarclt_Click(object sender, EventArgs e)
 {
     this.Close();
     c1 = new Thread(adicionar_Cliente);
     c1.TrySetApartmentState(ApartmentState.STA);
     c1.Start();
 }
Esempio n. 8
0
 //Informação Cliente
 private void btninformacaoclt_Click(object sender, EventArgs e)
 {
     this.Close();
     c3 = new Thread(informacao_Cliente);
     c3.TrySetApartmentState(ApartmentState.STA);
     c3.Start();
 }
Esempio n. 9
0
 //Informação Empregados
 private void btninformacaoemp_Click(object sender, EventArgs e)
 {
     this.Close();
     d3 = new Thread(informacao_Empregados);
     d3.TrySetApartmentState(ApartmentState.STA);
     d3.Start();
 }
 //Pagamento quartos
 private void btnpagamentoqrt_Click(object sender, EventArgs e)
 {
     this.Close();
     f5 = new Thread(pagamento_Quarto);
     f5.TrySetApartmentState(ApartmentState.STA);
     f5.Start();
 }
Esempio n. 11
0
 protected override void Execute(CodeActivityContext context)
 {
     try
     {
         Int32  _timeout = Timeout.Get(context);
         string data     = "";
         Thread.Sleep(_timeout);
         latch = new CountdownEvent(1);
         Thread td = new Thread(() =>
         {
             System.Windows.Forms.IDataObject clipBoardBefore = System.Windows.Forms.Clipboard.GetDataObject();
             if (clipBoardBefore.GetDataPresent(System.Windows.DataFormats.Text))
             {
                 data = (string)clipBoardBefore.GetData(System.Windows.DataFormats.Text);
             }
             refreshData(latch);
         });
         td.TrySetApartmentState(ApartmentState.STA);
         td.IsBackground = true;
         td.Start();
         latch.Wait();
         Result.Set(context, data);
     }
     catch (Exception e)
     {
         SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", e.Message);
         if (ContinueOnError.Get(context))
         {
         }
         else
         {
             throw;
         }
     }
 }
Esempio n. 12
0
 //adicionar empregados
 private void btnadicionaremp_Click(object sender, EventArgs e)
 {
     this.Close();
     d1 = new Thread(adicionar_Empregados);
     d1.TrySetApartmentState(ApartmentState.STA);
     d1.Start();
 }
        private void product_grid_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            int sum = 0;

            Product_order = mySQL.GetProduct_orderDataByOrderNumber(order_number_holder);
            Product       = mySQL.GetProductDataByBarcode(product_grid.CurrentRow.Cells[0].Value.ToString());

            for (int i = 0; i < Product_order.Length; i++)
            {
                if (Product_order[i].Product_serial_number == Product.Product_serial_number)
                {
                    if ((Product.Amount + previosAmount) - Convert.ToInt32(product_grid.CurrentRow.Cells[5].Value) >= 0)
                    {
                        sum += (Product.Amount + previosAmount) - Convert.ToInt32(product_grid.CurrentRow.Cells[5].Value);
                        mySQL.UpdateProduct_orderAmount(Product.Product_serial_number.ToString(), order_number_holder, Convert.ToInt32(product_grid.CurrentRow.Cells[5].Value));
                        mySQL.UpdateProductAmountByBarcode(sum, Product.Barcode);

                        MessageBox.Show("כמות עודכנה");

                        this.Close();
                        th = new Thread(openself);
                        th.TrySetApartmentState(ApartmentState.STA);
                        th.Start();
                    }
                    else
                    {
                        MessageBox.Show("לא מספיק מלאי לכמות המבוקשת");
                        this.Close();
                        th = new Thread(openself);
                        th.TrySetApartmentState(ApartmentState.STA);
                        th.Start();
                    }
                }
            }
        }
        private void remove_Click(object sender, EventArgs e)
        {
            Orderss = mySQL.GetOrdersDataByOrderNumber(Orderss.Order_number.ToString());                                                                //שולפים מידע להזמנה נוכחית

            if (Orderss.Status == 1)                                                                                                                    //בודק אם ההזמנה לא סופקה אז אפשר להסיר מוצרים
            {
                if (product_grid.Rows.Count != 0)                                                                                                       //אם הטבלה לא ריקה
                {
                    Product Product = mySQL.GetProductDataByBarcode(product_grid.CurrentRow.Cells[0].Value.ToString());                                 //מקבל מפרט של מוצר לפי ברקוד

                    mySQL.deleteProductFromProduct_cartByOrderNumberAndProductSerial(Product.Product_serial_number.ToString(), show_order_number.Text); //מסירים את המוצר הנבחר מההזמנה

                    if (Orderss.Status == 1)                                                                                                            //בודקים אם ההזמנה במצב לא סופק אז ניתן להחזיר כמות למוצר קיים
                    {
                        int sum = Product.Amount + Convert.ToInt32(product_grid.CurrentRow.Cells[5].Value);                                             //מחבר הכמות של המוצר שהוסר למוצר הקיים
                        mySQL.UpdateProductAmountByBarcode(sum, Product.Barcode);                                                                       //מוסיפים את כמות של המוצר שהוסר לכמות של המוצר הקיים במערכת
                    }

                    this.Close();

                    th = new Thread(openself);
                    th.TrySetApartmentState(ApartmentState.STA);
                    th.Start();
                }
            }
            else
            {
                MessageBox.Show("הזמנה סופקה , אין להסיר מוצרים");
            }
        }
Esempio n. 15
0
        private void btnExportToExcel_Click(object sender, EventArgs e)
        {
            Thread t = new Thread(Xls);

            t.TrySetApartmentState(ApartmentState.STA);
            t.Start();
        }
 //Informação quartos
 private void btninformacaoqrt_Click(object sender, EventArgs e)
 {
     this.Close();
     f3 = new Thread(informacao_Quarto);
     f3.TrySetApartmentState(ApartmentState.STA);
     f3.Start();
 }
Esempio n. 17
0
 //Registo cliente
 private void btnregistoemp_Click(object sender, EventArgs e)
 {
     this.Close();
     d4 = new Thread(registo_Empregados);
     d4.TrySetApartmentState(ApartmentState.STA);
     d4.Start();
 }
 //Check in quartos
 private void btncheclimqrt_Click(object sender, EventArgs e)
 {
     this.Close();
     f4 = new Thread(checkin_Quarto);
     f4.TrySetApartmentState(ApartmentState.STA);
     f4.Start();
 }
Esempio n. 19
0
        private static void StartUiThreads(Func <Window> createWindowFunc)
        {
            var wpfUiThread = new Thread(() =>
            {
                var app = new App();
                app.InitializeComponent();
                if (createWindowFunc is null)
                {
                    app.Run();
                }
                else
                {
                    app.Run(createWindowFunc());
                }
            });

            wpfUiThread.TrySetApartmentState(ApartmentState.STA);
            wpfUiThread.Start();

            var winformsThread = new Thread(() =>
            {
                System.Windows.Forms.Application.Run(BackgroundForm);
            });

            winformsThread.TrySetApartmentState(ApartmentState.STA);
            winformsThread.Start();


            while (App.Current is null)
            {
                Thread.Sleep(100);
            }
        }
Esempio n. 20
0
 private void btnsair_Click(object sender, EventArgs e)
 {
     this.Close();
     a1 = new Thread(voltar_Menu2);
     a1.TrySetApartmentState(ApartmentState.STA);
     a1.Start();
 }
Esempio n. 21
0
        /// <summary>Initialize the thread pool.</summary>
        /// <param name="workerThreadCount">Amount of worker threads to use</param>
        /// <param name="priority">ThreadPriority of the worker threads</param>
        public PriorityThread(int workerThreadCount, ThreadPriority priority)
        {
            if (workerThreadCount < _defaultMaxWorkerThreads)
            {
                workerThreadCount = _defaultMaxWorkerThreads;
            }

            // Create our thread stores; we handle synchronization ourself
            // as we may run into situtations where multiple operations need to be atomic.
            // We keep track of the threads we've created just for good measure; not actually
            // needed for any core functionality.
            _waitingCallbacks = new PriorityQueue();
            _workerThreads    = new ArrayList(workerThreadCount);
            _inUseThreads     = 0;

            // Create our "thread needed" event
            _workerThreadNeeded = new Semaphore(0);

            // Create all of the worker threads
            for (int i = 0; i < workerThreadCount; i++)
            {
                // Create a new thread and add it to the list of threads.
                Thread newThread = new Thread(new ThreadStart(ProcessQueuedItems));
                newThread.Name     = "PriorityThread #" + i.ToString();
                newThread.Priority = priority;
                _workerThreads.Add(newThread);

                // Configure the new thread and start it
                newThread.IsBackground = true;
                newThread.TrySetApartmentState(ApartmentState.MTA);
                newThread.Start();
            }
        }
Esempio n. 22
0
 //remover cliente
 private void btnremoverclt_Click(object sender, EventArgs e)
 {
     this.Close();
     c2 = new Thread(remover_Cliente);
     c2.TrySetApartmentState(ApartmentState.STA);
     c2.Start();
 }
Esempio n. 23
0
            /// <summary>
            /// 下载并打开word
            /// <param name="wordPic">word文件路径</param>
            /// <param name="wordName">word文件名</param>
            /// </summary>
            public int downloadAndOpenFile(string wordPic, string wordName)
            {
                System.Net.WebClient myWebClient = new System.Net.WebClient();
                string docDirectory = AppDomain.CurrentDomain.BaseDirectory + "docTempDirectory\\";

                if (false == System.IO.Directory.Exists(docDirectory))
                {
                    System.IO.Directory.CreateDirectory(docDirectory);
                }
                myWebClient.DownloadFile(MSConfig.host_lw_file_server_download + wordPic + "&name=" + wordName, docDirectory + wordName);
                ControlWordPanelService controlWordPanelService = new ControlWordPanelService();

                controlWordPanelService.updateDisplayFlagToShow();
                Thread thread = new Thread(new ThreadStart(delegate()
                {
                    ProcessStartInfo startInfo = new ProcessStartInfo();
                    startInfo.FileName         = "WINWORD.EXE";
                    startInfo.Arguments        = docDirectory + wordName;
                    try
                    {
                        Process.Start(startInfo);
                    }
                    catch (Exception e)
                    {
                        MSMessageBox.ShowModal(MSMessageBox.MSMessageBoxButton.OK, "错误", "Cannot start Microsoft Word, please make sure it is installed");
                    }
                }));

                thread.TrySetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();

                return(1);
            }
Esempio n. 24
0
 //Registo cliente
 private void btnregistoclt_Click(object sender, EventArgs e)
 {
     this.Close();
     c4 = new Thread(registo_Cliente);
     c4.TrySetApartmentState(ApartmentState.STA);
     c4.Start();
 }
Esempio n. 25
0
    /// <summary>
    /// Runs a fixture using the specified function to run it in a single thread apartment asynchronously.
    /// </summary>
    /// <typeparam name="TResult">The type of the result of a fixture running.</typeparam>
    /// <param name="run">The function to run a fixture.</param>
    /// <returns>The result of the fixture running.</returns>
    protected virtual Task <TResult> RunInStaAsync <TResult>(Func <TResult> run)
    {
        var taskCompletionSource = new TaskCompletionSource <TResult>();
        var thread = new Thread(() =>
        {
            try
            {
                taskCompletionSource.SetResult(run());
            }
            catch (Exception exc)
            {
                taskCompletionSource.SetException(exc);
            }
        })
        {
            IsBackground = true
        };

        try
        {
            thread.TrySetApartmentState(ApartmentState.STA);
        }
        catch
        {
            // ignored.
        }
        thread.Start();
        return(taskCompletionSource.Task);
    }
Esempio n. 26
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool x = false;

            if (codH.Text.Length != 0)
            {
                x = ControlaHoteis.RemoveHotel(Int32.Parse(codH.Text));
            }
            else
            {
                MessageBox.Show("Campos por preencher!!!");
            }

            if (x)
            {
                MessageBox.Show("O hotel foi removido com sucesso.");
                this.Hide();
            }
            else
            {
                MessageBox.Show("Hotel não existe!");
            }
            this.Close();
            m1 = new Thread(volta_Menu);
            m1.TrySetApartmentState(ApartmentState.STA);
            m1.Start();
        }
Esempio n. 27
0
 //Quartos livres hotel
 private void btnquartos_Click(object sender, EventArgs e)
 {
     this.Close();
     b4 = new Thread(quartos_Hotel);
     b4.TrySetApartmentState(ApartmentState.STA);
     b4.Start();
 }
Esempio n. 28
0
            /// <summary>
            /// 启动word进程
            /// </summary>
            public int startUpWordProcess()
            {
                int retVal = 0;
                ControlWordPanelService controlWordPanelService = new ControlWordPanelService();

                controlWordPanelService.updateDisplayFlagToShow();
                Thread thread = new Thread(new ThreadStart(delegate()
                {
                    System.Windows.Forms.OpenFileDialog file = new System.Windows.Forms.OpenFileDialog();
                    System.Windows.Forms.DialogResult result = file.ShowDialog();
                    if (System.Windows.Forms.DialogResult.OK == result)
                    {
                        ProcessStartInfo startInfo = new ProcessStartInfo();
                        startInfo.FileName         = "WINWORD.EXE";
                        startInfo.Arguments        = file.FileName;
                        try
                        {
                            Process.Start(startInfo);
                            retVal = 1;
                        }
                        catch (Exception e)
                        {
                            MSMessageBox.ShowModal(MSMessageBox.MSMessageBoxButton.OK, "错误", "Cannot start Microsoft Word, please make sure it is installed");
                        }
                    }
                }));

                thread.TrySetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();
                return(retVal);
            }
 //Adicionar quarto
 private void btnadicionarqrt_Click(object sender, EventArgs e)
 {
     this.Close();
     f1 = new Thread(adicionar_Quarto);
     f1.TrySetApartmentState(ApartmentState.STA);
     f1.Start();
 }
Esempio n. 30
0
        private void button1_Click(object sender, EventArgs e)
        {
            HotelBO h = new HotelBO();

            if (codH.Text.Length != 0)
            {
                ControlaHoteis.InfoHotel(Int32.Parse(codH.Text));
                if (Int32.Parse(codH.Text) == h.Cod)
                {
                    MessageBox.Show("Hotel Encontrado");
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Hotel não existe!");
                }
            }
            else
            {
                MessageBox.Show("Campos por preencher!!!");
            }
            this.Close();
            m1 = new Thread(volta_Menu);
            m1.TrySetApartmentState(ApartmentState.STA);
            m1.Start();
        }
Esempio n. 31
0
        private void CreateWindow()
        {
            _windowThread = new Thread(() =>
            {
                try
                {
                    _window = ReflectionHelper.CreateInstance(WpfReflectionHelper.PresentationFrameworkAssembly, "System.Windows.Window");
                    SubscribeToEvent(_window, "Loaded", "Window_Loaded");
                    SubscribeToEvent(_window, "Closing", "Window_Closing");
                    ReflectionHelper.SetProperty(_window, "ShowInTaskbar", true);
                    ReflectionHelper.SetProperty(_window, "ShowActivated", true);
                    ReflectionHelper.SetProperty(_window, "Width", 525);
                    ReflectionHelper.SetProperty(_window, "Height", 400);
                    ReflectionHelper.SetProperty(_window, "WindowStartupLocation", ReflectionHelper.GetStaticValue(WpfReflectionHelper.PresentationFrameworkAssembly, "System.Windows.WindowStartupLocation", "CenterScreen"));
                    ReflectionHelper.SetProperty(_window, "WindowStyle", ReflectionHelper.GetStaticValue(WpfReflectionHelper.PresentationFrameworkAssembly, "System.Windows.WindowStyle", "ToolWindow"));
                    ReflectionHelper.SetProperty(_window, "Title", "Alert");
                    var rootGrid = WpfReflectionHelper.CreateGrid();
                    WpfReflectionHelper.SetMargin(rootGrid, 5);
                    WpfReflectionHelper.AddAutoRowDefinition(rootGrid);
                    WpfReflectionHelper.AddStarRowDefinition(rootGrid);

                    var messageGrid = WpfReflectionHelper.CreateGrid();
                    WpfReflectionHelper.AddAutoColumnDefinition(messageGrid);
                    WpfReflectionHelper.AddStarColumnDefinition(messageGrid);

                    var image = ReflectionHelper.CreateInstance(WpfReflectionHelper.PresentationFrameworkAssembly,
                                                                "System.Windows.Controls.Image");
                    WpfReflectionHelper.SetMargin(image, 20);
                    var bitmapImage = Base64ToImage("iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAS/0lEQVR42u2ae6xlV33fP+uxn2efc+49996ZOw/PeLDnYWzjUY2NQTxK3cQlGLVBlKKmIqVBTZES2qZBNEFJIaFt1KZRUJRWqBUNtFJRTAKBPkJJIhVDoDEkwY9gbDxjz/vOfZ999tnPtVb/2Gfm3jtzZwDb+E5FtrS079065+y1vuv7+/5+6/f7KXboyr75T1/7E2+U73/gjvLN9+xn+PlH61M7MQ+1Ey+tV/7TjwX7HvycN/rGvcvnn73n/LnsXZHT337yonnspZ6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mPX6jl/J5nxIEDQszNzZMkiQg8gWsSqjqidENE7RDCIaRFaodUlrqxGGFYXc8pKoNSGhlFeHGC150nmLoV0TtKIQJMVpANz7G0cNqdPfE433r8CXfmVGXXhoebJuxWoj81Vp1BOtObWep0kqUoii5EUXQ+DMNzYRhe8H1/IQiCZa310DmXra2tVWmaNltM7hOf+IScnp5W/X7fi6IocM7FdV13y7LsV1U1U5blTFmWc0VRzJVFMZcXxUyRZ9N5nvXKIuvWVR41dRlYU3rYUps6V6bOpW1qITAi8oXQWhLHsZCuaXsAhWQ9LcjymjBQziGonHTa80H6zuJZ47RtjDYIr5EqLIMgLjudzjiKojSO4/UwDFejKFoOgmAxDMPFIAgWfd9fDoJgxff9dd/3R8aYfDwelysrK02WZfad73ynva53+eIXvyiCIJD9fl9prXUcx55zLvA8L6yqKjbGJMaYpGma3uZR13XXGNOt67rTNE3cNE1kjAmapvGNMZ4xRltrlXNWOndZm5wQwgkprJKqUUo1Sqlaa10qpUqtda61zrTWmed5qdZ6eMVIlVIjpVTm+/64LMtCKVWlaVqXZdmkaWqbprGvf/3r3fd8HN58nTx5UjjnRBiGMggCqbWWzjnl+752zmmllBZCeLR9TL619tLfnnNOW2v1xPVKNvrhxKYGISuEMM65RkrZCCEaoAZqKWUF1EKIummaevLcFEXRKKVMWZa2LEtb17UTQrhDhw65FyUf8D353TQVm6pAwvM8IYTAOdee7dpgQlyvY2ziLZwQwk3uGGMwxrQsEQIhBN1u1/GX119eL/j6f13TfTYXJjiZAAAAAElFTkSuQmCC");
                    ReflectionHelper.SetProperty(image, "Source", bitmapImage);
                    WpfReflectionHelper.AddChild(messageGrid, image);

                    var messageTextBlock =
                        ReflectionHelper.CreateInstance(WpfReflectionHelper.PresentationFrameworkAssembly,
                                                        "System.Windows.Controls.TextBlock");

                    WpfReflectionHelper.SetGridColumn(messageTextBlock, 1);
                    ReflectionHelper.SetProperty(messageTextBlock, "HorizontalAlignment", ReflectionHelper.GetEnumValue(WpfReflectionHelper.PresentationFrameworkAssembly, "System.Windows.HorizontalAlignment", "Left"));
                    ReflectionHelper.SetProperty(messageTextBlock, "TextWrapping", ReflectionHelper.GetEnumValue(WpfReflectionHelper.PresentationCoreAssembly, "System.Windows.TextWrapping", "Wrap"));
                    ReflectionHelper.SetProperty(messageTextBlock, "VerticalAlignment", ReflectionHelper.GetEnumValue(WpfReflectionHelper.PresentationFrameworkAssembly, "System.Windows.VerticalAlignment", "Center"));
                    ReflectionHelper.SetProperty(messageTextBlock, "FontSize", 18);
                    WpfReflectionHelper.SetBinding(messageTextBlock, "Message", "System.Windows.Controls.TextBlock", "TextProperty");
                    WpfReflectionHelper.AddChild(messageGrid, messageTextBlock);

                    var allAlertsGrid = WpfReflectionHelper.CreateGrid();
                    WpfReflectionHelper.SetGridRow(allAlertsGrid, 1);
                    WpfReflectionHelper.AddStarRowDefinition(allAlertsGrid);
                    WpfReflectionHelper.AddAutoRowDefinition(allAlertsGrid);
                    var dataGrid = ReflectionHelper.CreateInstance(WpfReflectionHelper.PresentationFrameworkAssembly,
                                                                   "System.Windows.Controls.DataGrid");
                    WpfReflectionHelper.SetBinding(dataGrid, "Items", "System.Windows.Controls.ItemsControl", "ItemsSourceProperty");
                    WpfReflectionHelper.AddChild(allAlertsGrid, dataGrid);
                    var closeButton = ReflectionHelper.CreateInstance(
                        WpfReflectionHelper.PresentationFrameworkAssembly, "System.Windows.Controls.Button");
                    SubscribeToEvent(closeButton, "Click", "ButtonOnClick");
                    WpfReflectionHelper.SetGridRow(closeButton, 1);
                    ReflectionHelper.SetProperty(closeButton, "Width", 100);
                    WpfReflectionHelper.SetMargin(closeButton, 0, 5, 0, 0);
                    ReflectionHelper.SetProperty(closeButton, "Content", "Close");
                    WpfReflectionHelper.AddChild(allAlertsGrid, closeButton);
                    
                    WpfReflectionHelper.AddChild(rootGrid, messageGrid);
                    WpfReflectionHelper.AddChild(rootGrid, allAlertsGrid);
                    
                    ReflectionHelper.SetProperty(_window, "Content", rootGrid);
                    _alertWindowModel = new AlertWindowModel();
                    ReflectionHelper.SetProperty(_window, "DataContext", _alertWindowModel);
                    
                    ReflectionHelper.InvokeMethod(_window, "ShowDialog");
                }
                catch (Exception exception)
                {                    
                }
            }
                )
            {
                IsBackground = false,
                Name = "Alert Window thread"
            };

            _windowThread.TrySetApartmentState(ApartmentState.STA);
            _windowThread.Start();
            LoadedEvent.WaitOne();
        }