Re-assigning RadDesktopAlertManager causes a "closed" event

13 posts, 1 answers
  1. David
    David avatar
    13 posts
    Member since:
    May 2015

    Posted 27 May Link to this post

    Hello, 

    I'm having a problem with RadDesktopAlertManager.
    Since its position can't be changed after initialization, I have to re-assign it in order to change the position. But after doing that, adding of a new RadDesktopAlert item to the manager causes a "Closed" event to be raised for the alert immediately after that (I can see in the Call Stack that the item's adding caused the event raising). Actually the item is not being closed (which is good), but the unnecessary event effects my business logic.

  2. Dimitar Dinev
    Admin
    Dimitar Dinev avatar
    7 posts

    Posted 30 May Link to this post

    Hi David,

    Thank you for the description.

    I tried to replicate the same behavior in a sample project but the Closed event is not being fired at my end when using the GetAllAlerts method to reposition the alert.

    Attached I'm sending you the sample project. Please, review it and if necessary update it with your logic and send it back to me so that I can further assist you.

    Regards,
    Dimitar Dinev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. David
    David avatar
    13 posts
    Member since:
    May 2015

    Posted 30 May in reply to Dimitar Dinev Link to this post

    Hi Dimitar, 

    Thanks for the answer.

    I see what happens. In my code, before re-instantiating the manager, I'm closing all the displaying alerts. The Closed event refers to those alerts, probably. The confusing thing is that it is being raised only after calling ShowAlert (after the re-instantiation), and not immediately after the call to CloseAllAlerts (as one would except).

  4. Dimitar Dinev
    Admin
    Dimitar Dinev avatar
    7 posts

    Posted 03 Jun Link to this post

    Hello David,

    Thank you for the feedback.

    As you described, I used the CloseAllAlerts method but the Closed event is raised as soon as the fading animation completes at my end and not after the ShowAlert method is invoked.

    I've made a small update in the attached sample project to demonstrate my approach. Please, review it and if I'm missing something of importance, update it with your logic and send it back to me. I will be awaiting your reply.
     
    Regards,
    Dimitar Dinev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. David
    David avatar
    13 posts
    Member since:
    May 2015

    Posted 03 Jun in reply to Dimitar Dinev Link to this post

    Hi Dimitar, 
    Thanks for the answer.

    I ran the sample you attached, and placed two breakpoints:

    1 - In the line "manager.ShowAlert(alert);"

    2 - In the begging of the method "Alert_Closed"

    The debugger first stopped in the 1st breakpoint, then it stopped in the 2nd one.

  6. Dimitar Dinev
    Admin
    Dimitar Dinev avatar
    7 posts

    Posted 04 Jun Link to this post

    Hi David,

    When I click Button_Click_1 the ShowAlert() method is called first at my end as you've described. The Alert_Closed method, however, is only called when the second button is clicked and the CloseAllAlerts() method is executed, which is expected.

    Could you please confirm that these are the same action steps you're taking at your end?

    If you're aiming for something different, please provide more details on your exact requirement so that I can further assist you. I will be awaiting your reply.

    Regards,
    Dimitar Dinev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  7. David
    David avatar
    13 posts
    Member since:
    May 2015

    Posted 11 Jun in reply to Dimitar Dinev Link to this post

    Hi Dimitar,

    I'm sorry for the misunderstood. I repeat the steps you write and got the same result. But, this is not the problem. In my previous post I mentioned that I placed two breakpoints, and the first one is in the line "manager.ShowAlert(alert);". I mean to the line that is in the method Button_Click_2. The Alert_Closed method is only called after that line (meaning, after ending the execution of Button_Click_2).

  8. Dimitar Dinev
    Admin
    Dimitar Dinev avatar
    7 posts

    Posted 11 Jun Link to this post

    Hi David,

    Thank you for the clarification.

    The reason why the breakpoint on manager.ShowAlert(alert) in Button_Click_2 is triggered first is because the CloseAllAlerts() method has a default fading animation which causes a delay in the alert's closing. Here is the method definition:

    public void CloseAllAlerts(bool useAnimations = true)
            {
                var alerts = new List<RadDesktopAlert>(this.openedAlerts);
                alerts.ForEach(alert => this.CloseAlert(alert, useAnimations));
                this.openedAlertsTotalHeight = 0;
            }

    You can ensure that the Closed event handler is called before the ShowAlert method by setting the bool value in ​Button_Click_2 to false ​like this:

    private void Button_Click_2(object sender, RoutedEventArgs e)
            {
                var alert = manager.GetAllAlerts().FirstOrDefault();
                manager.CloseAllAlerts(false);
                manager = new RadDesktopAlertManager(AlertScreenPosition.TopRight);
                manager.ShowAlert(alert);
            }

    Please let me know if this approach works for you.

    Regards,
    Dimitar Dinev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  9. David
    David avatar
    13 posts
    Member since:
    May 2015

    Posted 11 Jun in reply to Dimitar Dinev Link to this post

    No, it didn't help...

    I changed the argument value to false but the Alert_Closed method is still being called after the call to manager.ShowAlert(alert).

  10. Dimitar Dinev
    Admin
    Dimitar Dinev avatar
    7 posts

    Posted 11 Jun Link to this post

    Hi David,

    Attached I'm sending you a short video capture from my screen showcasing the code and behavior at my end. You can observe that the Closed event handler is called before the ShowAlert method on my machine.

    Could you please review it and give me feedback on whether your behavior differentiates from this one?

    Regards,
    Dimitar Dinev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  11. David
    David avatar
    13 posts
    Member since:
    May 2015

    Posted 13 Jun in reply to Dimitar Dinev Link to this post

    Hi Dimitar,

     

    That's very strange! When running the same code in my machine, the behavior is different. Maybe it's a bug that was solved in a newer version? I'm having an old version of Telerik installed (from 2016)

  12. Answer
    Dimitar Dinev
    Admin
    Dimitar Dinev avatar
    7 posts

    Posted 5 days and 15 hours ago Link to this post

    Hi David,

    I tested it with the 2016 R1 version and indeed the breakpoint on ShowAlert is hit first. This issue has been fixed in newer versions, so I would advise you to upgrade.

    You can learn more on how to Donwload New Versions and how to Upgrade the Wizard on the links provided.

    Regards,
    Dimitar Dinev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  13. David
    David avatar
    13 posts
    Member since:
    May 2015

    Posted 1 day and 21 hours ago in reply to Dimitar Dinev Link to this post

    OK, thanks.
Back to Top