473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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, 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 #1
9 2431
> 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, who´s 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dixp | last post by:
I'm new to writing multithreaded apps and I have a design question. I have a winforms app and a class which has a method that does processing which is time intensive. I want the user to be able...
47
by: mihai | last post by:
What does the standard say about those two? Is any assurance that the use of STL is thread safe? Have a nice day, Mihai.
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
5
by: sarge | last post by:
I would like to know how to perform simple multithreading. I had created a simple form to test out if I was multithreading properly, but got buggy results. Sometime the whole thig would lock up...
2
by: Rich | last post by:
Hello, I have set up a multithreading routine in a Test VB.net proj, and it appears to be working OK in debug mode and I am not using synchronization. Multithreading is a new thing for me, and...
55
by: Sam | last post by:
Hi, I have a serious issue using multithreading. A sample application showing my issue can be downloaded here: http://graphicsxp.free.fr/WindowsApplication11.zip The problem is that I need to...
5
by: sandy82 | last post by:
Whats actuallly multithreading is ... and how threading and multithreading differ . Can any1 guide how multithreading is used on the Web .. i mean a practical scenario in which u use...
2
by: Pradnya Patil | last post by:
hi , I am trying to draw ' html div-tag ' on the screen which will resemble a rectangle through vb.net code. I want it to be drawn faster...so I introduced multithreading using Threadpool. I...
7
by: Ray | last post by:
Hello, Greetings! I'm looking for a solid C++ multithreading book. Can you recommend one? I don't think I've seen a multithreading C++ book that everybody thinks is good (like Effective C++ or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.