I have a FileSystemWatcher that react on the Changed event.
I want to open the file, read its content display it in a textbox and hide the popup that has been created after 1 sec. The code almost work but something fail when hiding the popup.
Here is a snippet of the code :
       txtLog.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate() {
            this.txtLog.Text = dataToDisplay;
            extendedNotifyIcon_OnShowWindow();
            Thread threadToClosePopup = new Thread(new ThreadStart((Action)delegate() { 
                Thread.Sleep(1000); 
                extendedNotifyIcon_OnHideWindow();
       }));
            threadToClosePopup.Start();
        });
As you can see, I use the Invoke to set the text because the event is in a different thread (FileSystemWatcher). But to hide the windows the extendedNotifyIcon_OnHideWindow() is not executed in the thread of the GUI. How can I execute it in the GUI thread?