My Outlook 2010 add-in (using VSTO) does some web-service calls in a different thread when a mail is sent. I'd like to display a small non-modal pop-up notification (like those of Skype/yahoo/Windows live messenger) displaying the result of the web-service call.
I was trying to customize the Notification Window project as per my requirements. It seems to work fine when called from a click event handler of a form of my add-in using the following code:
private void btnOk_Click(object sender, EventArgs e)
{
PopupNotifier notifier = new PopupNotifier();
notifier.DisplayNotification("Test");
}
However, when the same method notifier.DisplayNotification("Test") is called from the background thread doing the web-service call, the notifier hangs; Its form is displayed on screen, but no text, color or animation seems to work. It just sits there until Outlook is closed.
I've done some searching and found that this might happen since the notifier is using the Show() method instead of ShowDialog() for displaying its form. And since I don't want a modal dialog for the pop-up notification, I can't change the method to ShowDialog() either.
According to other articles, I've also tried calling the method using backgroundWorkers, delegates, MethodInvoker, etc. but could not get the desired result.
However, while trying the above, I noticed that the same happens for not only the pop-up notifier, but any simple form. If I create it in the background thread and call the Show() method, it just gets stuck, whereas in the same situation ShowDialog() seems to work fine.
Any idea on how I could fix this would be greatly appreciated.
I eventually managed to solve the issue using the TaskbarNotifier project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With