This is a migrated thread and some comments may be shown as answers.

Re-assigning RadDesktopAlertManager causes a "closed" event

12 Answers 14 Views
DesktopAlert
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 27 May 2019, 02:17 PM

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.

12 Answers, 1 is accepted

Sort by
0
Dimitar Dinev
Telerik team
answered on 30 May 2019, 09:23 AM
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.
0
David
Top achievements
Rank 1
answered on 30 May 2019, 02:36 PM

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).

0
Dimitar Dinev
Telerik team
answered on 03 Jun 2019, 09:32 AM
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.
0
David
Top achievements
Rank 1
answered on 03 Jun 2019, 01:26 PM

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.

0
Dimitar Dinev
Telerik team
answered on 04 Jun 2019, 01:06 PM
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.
0
David
Top achievements
Rank 1
answered on 11 Jun 2019, 07:43 AM

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).

0
Dimitar Dinev
Telerik team
answered on 11 Jun 2019, 10:55 AM
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.
0
David
Top achievements
Rank 1
answered on 11 Jun 2019, 11:10 AM

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).

0
Dimitar Dinev
Telerik team
answered on 11 Jun 2019, 04:13 PM
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.
0
David
Top achievements
Rank 1
answered on 13 Jun 2019, 08:08 AM

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)

0
Accepted
Dimitar Dinev
Telerik team
answered on 14 Jun 2019, 04:07 PM
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.
0
David
Top achievements
Rank 1
answered on 18 Jun 2019, 09:26 AM
OK, thanks.
Tags
DesktopAlert
Asked by
David
Top achievements
Rank 1
Answers by
Dimitar Dinev
Telerik team
David
Top achievements
Rank 1
Share this question
or