使用多线程来加载大量页面内容吗? [英] Using multi threading to load a heavy page content or not?

查看:92
本文介绍了使用多线程来加载大量页面内容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Asp.Net应用程序,如果使用多线程加载沉重页面的内容对一种重要的操作来说徘徊的话,我会徘徊.假设有一个页面在其load_page方法中包含三个主要方法,并且这三个方法执行逻辑和繁重的操作,例如数据库访问和一些其他操作,这些操作可能会稍有延迟.那么,这三种方法应该在不同的线程中实现还是应该让它们在页面加载方法中执行?我真的希望页面的加载不干扰这些繁琐的操作.我应该怎么办?将这些方法从主页加载线程中分离出来,我会得到什么.
期待收到您的来信.

I am building an Asp.Net application and wander if it''s a sort of important to load a heavy page''s content using multithreading. Let suppose we have a certain page that contains three main methods in its load_page method, and that those three methods perform logic and heavy operations such as database access and some other operations that may delay a little. So, should those three methods be implemented in different threads or I should just let them in the page load method to be executed? I really want the page''s loading not to interfere with these heavy operations. What should I do? and what will I gain from separating these methods from the main page load''s thread.
Looking forward to hearing from you.

推荐答案

您正在向后思考.页面加载完全不会影响那些繁重的操作".这是繁重的操作,会影响页面加载.

由于内容正在生成页面上所查看的内容(我假设是!),直到完成这些操作后,用户才能看到页面.
You''re thinking about it a little backwards. The page load will not affect those "heavy operations" at all. It''s the heavy operations that will affect the page loading.

Since the content is generating what is viewed on the page (I''m assuming!) the user won''t see the page until those operations are done.


您好,

我更喜欢阅读异步方法调用.

请阅读 MSDN:ASP.NET中的异步方法调用 [ ^ ]

在Web应用程序中,您确实需要研究耗时方法的优化.您需要非常巧妙地设计UI,以便页面加载不会花费更多时间.您可以使用分页/标签/弹出页面/对话框.不要一口气加载所有内容.

除了调用Web方法/调用远程数据库/沉重的UI之外,应该没有任何耗时的方法.(甚至应该进行优化)

希望这些信息对您有帮助,
谢谢
-Amit Gajjar
Hi,

I prefer to read about Asynchronous method calling.

Please read MSDN : Async Method call in ASP.NET[^]

In web application, you really need to look into optimization of your time consuming methods. You need to design your UI very smartly so page load will not take more time. you can use Paging/Tabs/PopUp pages/Dialog box. Do not load everything in one go.

There should not be any timeconsuming method except Calling Web method/Calling remote database/ Heavy UI. (And even this should be optimize)

Hope this information helps you,
Thanks
-Amit Gajjar


这篇关于使用多线程来加载大量页面内容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆