471,082 Members | 727 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,082 software developers and data experts.

multithreading ASP.NET

hi,

i have found a example for multithreading and asp.net

http://www.fawcette.com/vsm/2002_11/...tures/chester/

i want to speed up my website ...

if my website is starting, they should build a database-connection and
send a few sqls

the code works fine without multithreading--- but if i call the method
as the example..:

Dim NewThread As Thread = New Thread(AddressOf threading)
NewThread.Priority = ThreadPriority.Lowest
NewThread.Start()

.....i get an error--means i have not set a objectreference
in the method i call a class, whos calling the access-database

the error raise at - setting the connection-string

oledbconnection1.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Us er ID=Admin;Data
Source=" & Server.MapPath("/~db/db.mdb") & _
";Mode=Share Deny None;Extended Properties=""""" & _
";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet
OLEDB:Database Pass" & _
"word="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking
Mode=1;Jet OLEDB:Glob" & _
"al Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet
OLEDB:New Databas" & _
"e Password="""";Jet OLEDB:Create System Database=False;Jet
OLEDB:Encrypt Database=" & _
"False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet
OLEDB:Compact Without Rep" & _
"lica Repair=False;Jet OLEDB:SFP=False"

any suggestions??
regards

tommy
Nov 18 '05 #1
9 2278
> oledbconnection1.ConnectionString =

Did you create oledbconnection1?

-Jimmy
Nov 18 '05 #2
Hi tommy:

The OleDbConnection variable must be null. Did you New it? Follow the
code with the debugger.

I'd strongly advise you to not look to threading first to improve the
performance of your web site. Look at other areas first - caching for
instance can make dramatic performance improvements with relatively
little work. The article was slanted towards saying threading is
always a performance gain, and this is not true. Adding threads in
ASP.NET can make things worse in some scenarios, and there are easier
ways to gain perf.

Take a look at this guide:

Improving .NET Application Performance and Scalability
http://www.microsoft.com/downloads/d...displaylang=en

--
Scott
http://www.OdeToCode.com/blogs/scott/

On 21 Oct 2004 12:29:41 -0700, th***********@hannover-leasing.de
(tommy) wrote:
hi,

i have found a example for multithreading and asp.net

http://www.fawcette.com/vsm/2002_11/...tures/chester/

i want to speed up my website ...

if my website is starting, they should build a database-connection and
send a few sqls

the code works fine without multithreading--- but if i call the method
as the example..:

Dim NewThread As Thread = New Thread(AddressOf threading)
NewThread.Priority = ThreadPriority.Lowest
NewThread.Start()

....i get an error--means i have not set a objectreference
in the method i call a class, whos calling the access-database

the error raise at - setting the connection-string

oledbconnection1.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";U ser ID=Admin;Data
Source=" & Server.MapPath("/~db/db.mdb") & _
";Mode=Share Deny None;Extended Properties=""""" & _
";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet
OLEDB:Database Pass" & _
"word="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking
Mode=1;Jet OLEDB:Glob" & _
"al Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet
OLEDB:New Databas" & _
"e Password="""";Jet OLEDB:Create System Database=False;Jet
OLEDB:Encrypt Database=" & _
"False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet
OLEDB:Compact Without Rep" & _
"lica Repair=False;Jet OLEDB:SFP=False"

any suggestions??
regards

tommy


Nov 18 '05 #3
Multithreading should be the last resort in ASP.NET application. Before going
there try to optimize your code or database with indexes. Multithreading in a
web application will usually get you in more trouble.

"tommy" wrote:
hi,

i have found a example for multithreading and asp.net

http://www.fawcette.com/vsm/2002_11/...tures/chester/

i want to speed up my website ...

if my website is starting, they should build a database-connection and
send a few sqls

the code works fine without multithreading--- but if i call the method
as the example..:

Dim NewThread As Thread = New Thread(AddressOf threading)
NewThread.Priority = ThreadPriority.Lowest
NewThread.Start()

.....i get an error--means i have not set a objectreference
in the method i call a class, who´s calling the access-database

the error raise at - setting the connection-string

oledbconnection1.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Us er ID=Admin;Data
Source=" & Server.MapPath("/~db/db.mdb") & _
";Mode=Share Deny None;Extended Properties=""""" & _
";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet
OLEDB:Database Pass" & _
"word="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking
Mode=1;Jet OLEDB:Glob" & _
"al Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet
OLEDB:New Databas" & _
"e Password="""";Jet OLEDB:Create System Database=False;Jet
OLEDB:Encrypt Database=" & _
"False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet
OLEDB:Compact Without Rep" & _
"lica Repair=False;Jet OLEDB:SFP=False"

any suggestions??
regards

tommy

Nov 18 '05 #4
"tommy" <th***********@hannover-leasing.de> wrote in message
news:8f**************************@posting.google.c om...
hi,

i have found a example for multithreading and asp.net

http://www.fawcette.com/vsm/2002_11/...tures/chester/

i want to speed up my website ...


Do not use this example!!!

First of all, I strongly suggest you ignore any article about _using_ a
feature if it has to spend most of its time explaining what the feature
_is_. Most of that article attempts to teach what threads are!

Second, the GeneratePrimeNumbers() method references "Session". Within a web
form, "Session" refers to "Page.Session". This will be problematic when this
code is still executing after the Page has finished executing and the Page
instance has been deleted or trashed by ASP.NET. ASP.NET does not guarantee
you that the Page will be in any way useful after it is finished executing.
In particular, nothing should be referencing that Page or anything on it
after Page.Dispose has been called.

The code then proceeds to reference other member variables of the Page!

The author does not demonstrate an understanding of the ASP.NET page
lifecycle. I strongly recommend that you do better than the author and learn
how ASP.NET works with features it actually supports before you try to use
it with features for which it provides no support at all, namely
multithreading. Otherwise, you'll find yourself implementing this
misunderstanding of ASP.NET in an application where it actually matters,
instead of in a prime number generation program.

---
John Saunders
Nov 18 '05 #5
You can create more threads in your ASP.NET application in normal way,
and the thread still run even there is no active session :)
Nov 18 '05 #6
hello,

thank you all for reply.

the "why" i want to do this is, because i have a forum-website -- where
the contributions are hierarchically.

for every node, i have to send a sql to database
for more contributions, the display of website takes more time

so i want to display the website at request--- and for every database
return, i referesh the site....
regards

tommy
----------------------------------------
HangulHanjaFastConversion-Eigenschaft

True if Microsoft Word automatically converts a word with
only one suggestion during conversion between hangul
and hanja. Read/write Boolean.
----------------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #7
My guess is you'll find more perf improvements by using caching, and
by optimizing the SQL to avoid a query for every node. Is this a SQL
Server backend? You might want to investigate returning form
information in a hierarchy by using XML from SQL and avoid round trips
to the database.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 22 Oct 2004 00:32:49 -0700, RASTA
<th***********@hannover-NOSPAM-leasing.de> wrote:
hello,

thank you all for reply.

the "why" i want to do this is, because i have a forum-website -- where
the contributions are hierarchically.

for every node, i have to send a sql to database
for more contributions, the display of website takes more time

so i want to display the website at request--- and for every database
return, i referesh the site....
regards

tommy
----------------------------------------
HangulHanjaFastConversion-Eigenschaft

True if Microsoft Word automatically converts a word with
only one suggestion during conversion between hangul
and hanja. Read/write Boolean.
----------------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 18 '05 #8
"Tien" <ti****@gmail.com> wrote in message
news:1d*************************@posting.google.co m...
You can create more threads in your ASP.NET application in normal way,
and the thread still run even there is no active session :)


The thread may run, but it is invalid for such a thread to reference objects
from the Page, since the page may be gone by the time thread gets around to
running.

-----
John Saunders
Nov 18 '05 #9
As others have mentioned it seems to be a design flaw more than anything else.
the "why" i want to do this is, because i have a forum-website -- where
the contributions are hierarchically.
How would threading help you with your hierarchical nodes problems?
and for every database return, i referesh the site....
How would browser know when a certain thread is completed "database return"
running on the server.

I think the answer is caching, better indexing and better design rather than
threading. Also you might want to pre-process heavy duty tasks like building
hierarchical nodes structure on back-end, schedule a SQL job or something
like that.

Let me just reiterate that doing threading in a web application will get you
in more trouble than you trying to solve originally. I learned from my own
painful experience. Keep multithreading in Windows apps, and stick to
Response/Request HTTP way of doing things in ASP.NET.
"RASTA" wrote:
hello,

thank you all for reply.

the "why" i want to do this is, because i have a forum-website -- where
the contributions are hierarchically.

for every node, i have to send a sql to database
for more contributions, the display of website takes more time

so i want to display the website at request--- and for every database
return, i referesh the site....
regards

tommy
----------------------------------------
HangulHanjaFastConversion-Eigenschaft

True if Microsoft Word automatically converts a word with
only one suggestion during conversion between hangul
and hanja. Read/write Boolean.
----------------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by dixp | last post: by
47 posts views Thread by mihai | last post: by
16 posts views Thread by Robert Zurer | last post: by
5 posts views Thread by sarge | last post: by
2 posts views Thread by Rich | last post: by
55 posts views Thread by Sam | last post: by
5 posts views Thread by sandy82 | last post: by
2 posts views Thread by Pradnya Patil | last post: by
7 posts views Thread by Ray | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.