By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,163 Members | 1,286 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,163 IT Pros & Developers. It's quick & easy.

BackGroundWorker for .NET 1.1?

P: n/a
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
Feb 18 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
You need to create a seperate thread to load the data. Is this what you are
asking to do?

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Mitchell Vincent" <mv******@newsgroup.nospam> wrote in message
news:e9**************@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

Feb 18 '06 #2

P: n/a
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
Feb 18 '06 #3

P: n/a
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...;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/micro...&start=1&num=3
--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Mitchell Vincent" <mv******@newsgroup.nospam> wrote in message
news:e0**************@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

Feb 18 '06 #4

P: n/a
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?
"Mitchell Vincent" <mv******@newsgroup.nospam> wrote in message
news:e9**************@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

Feb 19 '06 #5

P: n/a
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/art...undWorker.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.
================================================== ====

Feb 20 '06 #6

P: n/a
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...nousOperations

--

Best 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" <mv******@newsgroup.nospam> escribió en el mensaje
news:e9**************@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

Feb 20 '06 #7

P: n/a
Awesome information guys, many thanks!

--
- Mitchell Vincent
Feb 21 '06 #8

P: n/a
You should check out Ken Getz article in the March 2005 MSDN mag. http://msdn.microsoft.com/msdnmag/is...s/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
Feb 22 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.