|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
BackGroundWorker for .NET 1.1?an article about performance and the small(er) things you can do to improve it. I have a pretty big database driven winforms application that I've been working on and am very disappointed in the time it takes to show some of these windows. I am doing a lot of data binding and database access in the form's loading event. I do SuspendLayout/ResumeLayout around the code in my _load event but that really only makes it *appear* to "pop" faster. I read about .NET 2.0's BackgroundWorker support and was intrigued. I can't afford the move to 2.0 yet as virtually no one has it installed, so I'm looking for a solution that will work with .NET 1.1. Is starting a new thread in the load event "proper"? In order to data bind I need to run at least a SELECT query, so is there some harm in binding in a thread other than the main one? Obviously it does me no good to show a window that the user can't interact with, but even shaving half a second off the load time would be a substantial improvement. Even fractions of a second *appear* to be a long time when just opening a window. -- - Mitchell Vincent You need to create a seperate thread to load the data. Is this what you are
asking to do? -- Show quoteHide quoteGet a powerful web, database, application, and email hosting with KJM Solutions http://www.kjmsolutions.com "Mitchell Vincent" <mvincent@newsgroup.nospam> wrote in message news:e9BqRhLNGHA.1032@TK2MSFTNGP11.phx.gbl... >I just read my MSDN magazine from last month and was very pleased to see an >article about performance and the small(er) things you can do to improve >it. > > I have a pretty big database driven winforms application that I've been > working on and am very disappointed in the time it takes to show some of > these windows. I am doing a lot of data binding and database access in the > form's loading event. I do SuspendLayout/ResumeLayout around the code in > my _load event but that really only makes it *appear* to "pop" faster. > > I read about .NET 2.0's BackgroundWorker support and was intrigued. I > can't afford the move to 2.0 yet as virtually no one has it installed, so > I'm looking for a solution that will work with .NET 1.1. Is starting a new > thread in the load event "proper"? In order to data bind I need to run at > least a SELECT query, so is there some harm in binding in a thread other > than the main one? > > Obviously it does me no good to show a window that the user can't interact > with, but even shaving half a second off the load time would be a > substantial improvement. Even fractions of a second *appear* to be a long > time when just opening a window. > > -- > - Mitchell Vincent vbnetdev wrote:
> You need to create a seperate thread to load the data. Is this what you are Basically, yes, and asking if that is a good or bad idea (and why if > asking to do? > it's either!). I want to display those forms as fast as possible but as soon as they are displayed the user will want to interact with them. It makes sense I'd load everything up *before* I show for form. Should I maybe move the database work/binding to the window's class constructor? -- - Mitchell Vincent Well there are a couple schools of thought on this. One of the advances of
VS 2005 is it attempts to have you use delegates so that your actions are thread safe. But what I will do is give you a link and let you decide. http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q315577 load your dataset as you do normally in threadtask. I load what i need and disable any interative capability until complete. I load the data in another for appearance sake (to keep the form from appearing like it is not responding) during this time. Of course then I assign it ot the datagrid. However..... You will get an exception in VS2005 doing this as your datagrid will access a thread that is not its owner. This can be disabled. But a study of delegates will resolve this. http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/7bf688aa4c2afa05/c5d3077ceda3ac61%23c5d3077ceda3ac61?sa=X&oi=groupsr&start=1&num=3 -- Show quoteHide quoteGet a powerful web, database, application, and email hosting with KJM Solutions http://www.kjmsolutions.com "Mitchell Vincent" <mvincent@newsgroup.nospam> wrote in message news:e0BaARMNGHA.3944@tk2msftngp13.phx.gbl... > vbnetdev wrote: >> You need to create a seperate thread to load the data. Is this what you >> are asking to do? >> > > Basically, yes, and asking if that is a good or bad idea (and why if it's > either!). > > I want to display those forms as fast as possible but as soon as they are > displayed the user will want to interact with them. It makes sense I'd > load everything up *before* I show for form. Should I maybe move the > database work/binding to the window's class constructor? > > > -- > - Mitchell Vincent Hi Mitchell,
Thanks for posting! As other communicators mentioned, there are many ways to approach current issue. If you want to implement the Backgroundworker in .NET 1.1, the following article demonstrates how to implement the Backgroundworker in C sharp: http://weblogs.asp.net/rosherove/articles/BackgroundWorker.aspx I hope this will be helpful! Regards, Yuan Ren [MSFT] Microsoft Online Support ====================================================== PLEASE NOTE the newsgroup SECURE CODE and PASSWORD were updated on February 14, 2006. Please complete a re-registration process by entering the secure code mmpng06 when prompted. Once you have entered the secure code mmpng06, you will be able to update your profile and access the partner newsgroups. ====================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from this issue. ====================================================== This posting is provided "AS IS" with no warranties, and confers no rights. ====================================================== Just wondering... Have you tested which part exactly takes such a long time?
Do you maybe have a client side cursor with a full table read? Show quoteHide quote "Mitchell Vincent" <mvincent@newsgroup.nospam> wrote in message news:e9BqRhLNGHA.1032@TK2MSFTNGP11.phx.gbl... >I just read my MSDN magazine from last month and was very pleased to see an >article about performance and the small(er) things you can do to improve >it. > > I have a pretty big database driven winforms application that I've been > working on and am very disappointed in the time it takes to show some of > these windows. I am doing a lot of data binding and database access in the > form's loading event. I do SuspendLayout/ResumeLayout around the code in > my _load event but that really only makes it *appear* to "pop" faster. > > I read about .NET 2.0's BackgroundWorker support and was intrigued. I > can't afford the move to 2.0 yet as virtually no one has it installed, so > I'm looking for a solution that will work with .NET 1.1. Is starting a new > thread in the load event "proper"? In order to data bind I need to run at > least a SELECT query, so is there some harm in binding in a thread other > than the main one? > > Obviously it does me no good to show a window that the user can't interact > with, but even shaving half a second off the load time would be a > substantial improvement. Even fractions of a second *appear* to be a long > time when just opening a window. > > -- > - Mitchell Vincent Hi Mitchell,
The following articles show how to use asynchronous operations (before .NET 2.0): Resources about asynchronous operations http://www.mztools.com/resources_net_developers.htm#AsynchronousOperations -- Show quoteHide quoteBest regards, Carlos J. Quintero MZ-Tools: Productivity add-ins for Visual Studio You can code, design and document much faster: http://www.mztools.com "Mitchell Vincent" <mvincent@newsgroup.nospam> escribió en el mensaje news:e9BqRhLNGHA.1032@TK2MSFTNGP11.phx.gbl... >I just read my MSDN magazine from last month and was very pleased to see an >article about performance and the small(er) things you can do to improve >it. > > I have a pretty big database driven winforms application that I've been > working on and am very disappointed in the time it takes to show some of > these windows. I am doing a lot of data binding and database access in the > form's loading event. I do SuspendLayout/ResumeLayout around the code in > my _load event but that really only makes it *appear* to "pop" faster. > > I read about .NET 2.0's BackgroundWorker support and was intrigued. I > can't afford the move to 2.0 yet as virtually no one has it installed, so > I'm looking for a solution that will work with .NET 1.1. Is starting a new > thread in the load event "proper"? In order to data bind I need to run at > least a SELECT query, so is there some harm in binding in a thread other > than the main one? > > Obviously it does me no good to show a window that the user can't interact > with, but even shaving half a second off the load time would be a > substantial improvement. Even fractions of a second *appear* to be a long > time when just opening a window. > > -- > - Mitchell Vincent You should check out Ken Getz article in the March 2005 MSDN mag. http://msdn.microsoft.com/msdnmag/issues/05/03/AdvancedBasics/default.aspx.
Also, make sure to read the previous articles he mentions if you plan to stay on 1.1 as you indicated. Jim Wooley |
|||||||||||||||||||||||