Answered Notification in thread

  • Thursday, January 05, 2012 11:40 AM
     
     

    Hi,

    I use a notification balloon in my application to alert users about a specific event.When the BalloonChangedEvent is fired, I dispose the notification.

    When I call notification from the UI (e.g. a button click), the balloon is disposed correctly but when I call it from a background thread, the event never fires up.

    Thanks,

All Replies

  • Friday, January 06, 2012 6:27 PM
     
     Answered
    1. Raise and event in your background thread. 
    2. Add a handler for that event to your UI code.
    3. Inside the event code handler, Invoke a Delegate method to change the state of the UI.  You cannot change the UI directly from the event, you must Invoke a Delegate to allow the STAThread process to execute the change.

    Dick


    Dick Grier. Author of Visual Basic Programmer's Guide to Serial Communications 4. See www.hardandsoftware.net.
  • Monday, January 09, 2012 9:20 AM
     
     Answered Has Code

    Hi,

    Thank you for your answer.

    I finally used Action class to show the nofitication

    Invoke(new Action(() => ShowMessage()));
    

    and it worked perfect.