I'm building a monitor folders using FileSystemWatcher (in WPF), and need to show the changes of the folders in popups in System Tray. I am using the library "NotifyIcon" to this (https://visualstudiogallery.msdn.microsoft.com/aacbc77c-4ef6-456f-80b7-1f157c2909f7/) but when run the application when it passes through the routine instantiates the object, an error occurs. I've had this problem before and managed to solve with the dispatcher, but now I'm having this problem in the instance of an object from an external library of visual studio (the NotifyIcon to the development of popups), I do not know how to solve. I've read some answers here in the forum, but nothing that has to do with instances of objects. I can't post any images, because i don't have enough reputation, but' i'll post the code. Sorry if vague question, or if the text contains errors, my English is not very good. Any doubts about the question, please ask me. hugs ~
private void On_Created(object sender, System.IO.FileSystemEventArgs e)
{
ShowChanges(e.ChangeType, e.Name);
Thread criacao = new Thread(new ThreadStart(NotifyCreated));
criacao.SetApartmentState(ApartmentState.STA);
criacao.Start();
}
private void NotifyCreated()
{
//the error occours here\/
TaskbarIcon NotificaCriacao = new TaskbarIcon();
string titulo = "Notificação de Ocorrencia";
string ocorrencia = "Ocorrencia";
NotificaCriacao.ShowBalloonTip(titulo, ocorrencia, BalloonIcon.Error);
}