如何避免在Flex中显示多个警报窗口

发布于 2024-10-17 21:17:41 字数 328 浏览 5 评论 0原文

我的应用程序中有一个计时器。每 30 分钟,它将访问 Web 服务并获取数据并更新 UI。直到昨天,该应用程序都运行良好。突然,由于某些问题,网络服务有一段时间无法使用。在此期间,应用程序在警报窗口中多次显示 RPC 错误(超过 100 个警报框)。由于这个警告框,我的应用程序被挂起,我无法执行任何操作。

我尝试了几种方法,但没有任何效果。最后,我尝试使用标志。在所有的方法中,这看起来都是有希望的。所以我已经实现了它。基本上,在这种方法中,每当我们打开警报时,我们都会设置一个标志。在打开和关闭警报时,我们将重置该标志。但它并没有按预期工作。有什么方法可以帮助我们避免多个警报窗口。

请帮助我解决这个问题。

I have a timer in my application. For every 30 min, it will hit the web services and fetch the data and updates the UI. The application was working fine till yesterday. Suddenly, because of some issue, the web services were not available for some time. During that period, Application displayed the RPC Error multiple times(More than 100 alert boxes) in alert window. Because of this alert boxes, my application was hanged and i was not able to do anything.

I have tried several approaches, but nothing worked.Finally, I have tried to use a flag. In all the approaches, this looked promising. so i have implemented it.Basically, in this approach whenever we open an alert we will set a flag.While opening and closing alert we will reset this flag. But it didn't work as expected. Is there any approach, which can help us in avoiding multiple alert windows.

Please help me, to fix this issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

万劫不复 2024-10-24 21:17:41

我会编写用于打开警报的包装器,并仅使用此包装器,而不是代码中的 Alert.show:

public class AlertWrapper {

   private static var lastAlert:Alert;

   public static function showAlert(text:String, title:String):void {
       if (lastAlert) {
            PopUpManager.removePopUp(lastAlert);
            //or
            //return; //ignore last alert
       }
       lastAlert = Alert.show(text, title, null, 4, onAlertClose);
   }

   private static function onAlertClose(event:CloseEvent):void {
       lastAlert = null;
   }
}

缺少导入,但我希望这个想法很清楚。

I would write wrapper for opening alerts, and use only this wrapper, not Alert.show in the code:

public class AlertWrapper {

   private static var lastAlert:Alert;

   public static function showAlert(text:String, title:String):void {
       if (lastAlert) {
            PopUpManager.removePopUp(lastAlert);
            //or
            //return; //ignore last alert
       }
       lastAlert = Alert.show(text, title, null, 4, onAlertClose);
   }

   private static function onAlertClose(event:CloseEvent):void {
       lastAlert = null;
   }
}

Imports are missing, but I hope the idea is clear.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文