如何在应用程序加载时检查正在加载哪些资源?

发布于 2024-10-08 10:41:12 字数 244 浏览 0 评论 0原文

我想向用户展示我的应用程序加载时正在加载哪些资源。

示例:加载模块...

他们真的检查一些资源并加载它们吗 如果是。请帮助我编写在普通 C Sharp/wpf 应用程序中执行相同操作的代码 使用闪屏和进度条。 以及如何跟踪加载内容的进度。 一个例子可以更好地帮助我。

我正在创建一个包含 4 个模块的应用程序。 患者、医生、住院患者、内置数据。 启动屏幕后,将显示登录表单。成功登录后,将显示菜单以从 4 个模块中进行选择。

I want to show the user what resources are loading while my application is loading.

example: loading modules...

do they really check some resources and load them
if yes. please help me with the code to do the same in an normal C sharp/wpf application
using splash screen and progress bar.
also how to track the progress of loading stuffs.
an example would help me in a better way.

I am creating an application with 4 modules.
Patient, Doctor,Inpatient,Inbuilt data.
After splash screen, a log in form is shown. and after successful log in menu is shown to choose from 4 modules.

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

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

发布评论

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

评论(1

¢蛋碎的人ぎ生 2024-10-15 10:41:12

所有资源都在编译时链接。

对象是在您创建它们时在运行时创建的。

诀窍是管理您的对象创建。您应该在构造函数中执行此操作,而不是在声明部分中启动所有成员,这样您就可以对加载过程提供某种反馈。

不好的例子:

Class blah 
{
   private A a = new A();
   private B b = new B();

   public blah() { }
}

如果你这样做,对象会“自动”创建,并且你无法获得有关该过程的任何反馈(如果 A 或 B 失败,或者抛出异常,你可能会遇到致命错误......这很难进行调试)。

正确的方法应该是:

Class blah 
{
   private A a;
   private B b;

   public blah() 
   {
      A = new A();
      //Send some message that A succeeded 
      B = new B();
      //Send some message that B succeeded
   }
}

这样你就可以跟踪对象的创建过程。
之后您所要做的就是捕获消息(您可以使用事件),并将数据转发到进程栏或其他东西。

All the resources are linked at compile time.

Objects are created at run time when you create them.

The trick is to manage your object creation. Instead of initiating all the members in the declaration part, you should do that in the constructor, that way you can give some kind of feedback on the loading process.

Bad example:

Class blah 
{
   private A a = new A();
   private B b = new B();

   public blah() { }
}

if you do it that way, the object is created "automatically" and you can't get any feedback about the process (and you could have fatal errors if A or B fail, or throw an exception... it's hard to debug).

The right way should be:

Class blah 
{
   private A a;
   private B b;

   public blah() 
   {
      A = new A();
      //Send some message that A succeeded 
      B = new B();
      //Send some message that B succeeded
   }
}

This way you can keep track of the object's creation process.
All you have to do after that is just catch the messages (you can use events), and relay the data to a process bar or something.

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