Toast Notification

Hi Team,

I am trying to use show method of toast notification in my automation, but I am getting below exception.

“The calling thread must be STA, because many UI components require this.”

Could you please let me know how to resolve this.

@LaxmiVenkataMownK I believe that these must be shown off of a Windows Form thread based on this error. If you don’t have a Windows Form in your solution, you can basically have a hidden one by doing the following. The form must technically be visible for this to work, so make sure it isn’t explicitly hidden. It will be invisible to a user however.

  1. Set the Form’s ShowInTaskBar property to False.
  2. Set the Form’s Opacity to 100%.
  3. Add a button to the form.
  4. Use the button’s Click event to show your toast notification.
  5. To show the Toast notification in an automation, call the PerformClick method on your Form’s button.

This really helps. Thank you @ThomasSasnett