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 sho开发者_开发百科wn to choose from 4 modules.
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.
精彩评论