Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why this code
Message
From
13/04/2011 07:22:53
 
 
To
12/04/2011 13:17:22
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP1
Application:
Desktop
Miscellaneous
Thread ID:
01507029
Message ID:
01507113
Views:
50
>>>Hello all,
>>>
>>>First of all, if this gets posted twice I appologize. I clicked send and got a blank form back so it doesn't appear to have been posted. I am retyping the entire question again.
>>>
>>>I am reviewing some code that I did not write and wondering if you can help me understand why this might have been done this way. Why not just call the method directly. This application is a WPF application.
>>>
>>>
>>>public App()
>>>{
>>>      fSplashScreen = new SplashScreen("/Resources/Splash.png");
>>>      fSplashScreen.Show(false);
>>>      GISGlobals.GISCommunicator = GISCommunicator.Current;
>>>
>>>      // Why might this be done this way.
>>>      InitStartUpXmlSerializiersExecute lInitSerializers = new InitStartUpXmlSerializiersExecute(InitStartUpXmlSerializiers);
>>>      lInitSerializers.Invoke();
>>>}
>>>
>>>protected void InitStartUpXmlSerializiers()
>>>{
>>>      Communicator.GetXmlSerializer(typeof(DBSearchResultList));
>>>      Communicator.GetXmlSerializer(typeof(DBSiteList));
>>>      Communicator.GetXmlSerializer(typeof(DBRanges));
>>>      // Times 17 of these Serializers
>>>}
>>>
>>>
>>>This application takes about 8-13 seconds just to show a login form. This portion is taking about 30% of that time. The question though is why would they have not just called this method directly?
>>
>>What does 'InitStartUpXmlSerializiersExecute' look like ?
>
>
>
>'protected delegate void InitStartUpXmlSerializiersExecute();
>
I can see no point in the construct. Don't think Dispatcher.BeginInvoke would be of great benefit either since it will still tie up the UI thread. Why not just use a BackgroundWorker:
        private BackgroundWorker bw;

        public App()
        {
            bw = new BackgroundWorker();
            bw.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
            bw.RunWorkerAsync();
            fSplashScreen = new SplashScreen("/Resources/Splash.png");
            fSplashScreen.Show(false);
        }

        void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            Communicator.GetXmlSerializer(typeof(DBSearchResultList));
            Communicator.GetXmlSerializer(typeof(DBSiteList));
            Communicator.GetXmlSerializer(typeof(DBRanges));
        }
You'd probably want to provide some indication of when all of the GetXmlSerializer() methods have completed ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform