关于 .net 后台处理的建议

发布于 2024-09-25 21:56:36 字数 242 浏览 8 评论 0原文

我有一个从外部源读取数据的网页。检索数据可能需要一段时间。

我想知道是否有人可以给我一个关于在后台发生这种情况的最佳方法的想法。我希望页面出现并在最终显示数据的面板中显示“正在处理”(或类似的内容)。

我想到了BackgroundWorker组件,或者可能是AsyncPostBackTrigger...不确定这些是否能解决令我满意的问题。

那么...有人对解决问题的好方法有任何想法吗?

谢谢你的建议!!

I have a webpage that reads data from an external source. It can take awhile to retrieve the data.

I was wondering if someone could give me an idea on the best way to have this happen in the background. I would like the page to come up and display 'Processing' (or somthing like that) in the panel where the data will eventually be displayed.

I thought of the BackgroundWorker component, or maybe an AsyncPostBackTrigger... not sure if these will even solve the problem to my satisfaction.

So... does anyone have any ideas as to a good approach to the problem?

Thanks for the advice!!

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

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

发布评论

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

评论(4

李不 2024-10-02 21:56:36

我认为您正在寻找的是Ajax 您希望以允许用户继续查看其他内容直到加载为止的方式从客户端发出请求。

.NET 有许多不同的技术来支持 AJAX 请求 - 范围从 UpdatePanel 控制异步操作< /a>.您使用哪种技术取决于您想要执行的具体操作的细节。

您还可以仅使用 jQuery 之类的库向 Web 应用程序中的单独页面或服务发出内容异步请求。

I think what you're looking for is Ajax. You want to make the request from the client side in a way that will allow the user to continue viewing other content until that loads.

.NET has a number of different techniques for support AJAX requests - ranging from UpdatePanel controls to Async Operations. Which technique you use depends on the details of exactly what you're trying to do.

You could also just use a library like jQuery to make async requests for content to a separate page or service in your web application.

旧人九事 2024-10-02 21:56:36

我将使用 AJAX,将页面与处理消息一起发送给用户,然后使用 JavaScript 从 XmlHttpRequest 请求外部源(通过您的站点作为代理)。

I would use AJAX, send the page to the user with a processing message, then request the external source from a XmlHttpRequest using JavaScript (through your site as a proxy).

悟红尘 2024-10-02 21:56:36

好吧,一种解决方案是在更新面板*内的页面上粘贴 asp:Timer。让 OnTick 事件检索处理的当前状态(进度百分比、是否完成、正在做什么等)。处理部分可以通过多种方式通知页面其进度;一种方法是给它一个进度属性并在运行时更新它。请注意,OnTick 事件不会进行处理;只是为了弄清楚处理的状态。

*如果你把它放在更新面板之外,它会勾选每个Interval而不是每个Timer.Interval + TimeToReloadUpdatePanel,如果TimeToReloadUpdatePanel >,这将是一个大问题;=计时器.间隔

Well, one solution is to stick an asp:Timer on your page inside an update panel*. Have the OnTick event retrieve the current status of the processing (progress percentage, if it's done, what it's doing, etc.). There are various ways the the processing part can notify the page of its progress; just giving it a progress property and updating it as it runs is one way to do it. Note that the OnTick event will NOT be doing the processing; it is just to figure out the status of the processing.

*If you put it outside the update panel, it will tick every Interval instead of every Timer.Interval + TimeToReloadUpdatePanel, which will be a big problem if TimeToReloadUpdatePanel >= Timer.Interval.

各空 2024-10-02 21:56:36

我的想法是网络查询应该很快,所以我会寻找提高查询性能的方法。如果每个查询的数据都相同,我会尝试缓存它。如果这不可行,我将使用 jQuery 发出异步请求并显示加载图像,直到查询完成。

My thinking is that web queries should be fast so I would look for ways to improve the query performance. If the data is going to be the same for each query, I would try caching it. If that is not feasible, I would use jQuery to make an async request and display a loading image until the query finishes.

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