473,404 Members | 2,114 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,404 software developers and data experts.

Single or multiple thread?

Suppose a base class like

partial class X : Page ...

and a class A that is called from class X somewhere along the code.

I'm not able to understand if for each user connected to the web site, a
thread is created and so every call to class A stay in different thread or
all works into a single thread.

I'm asking this because I've a function the get the last ID of a table in
the db, but I'm worried about that multiple call can return the same number
at same time (since I just get the number) and after I increment it.

What could be a solution? In a multiple thread scenario, the lock statement
sounds good ... but I'm not sure about the scenario it represents.

Thanks
Andrea

Mar 23 '06 #1
2 1546
there is a thread for each current request, with one exception. only one
active request per session is allowed (others are queued). also during the
processing of the page, the request thread may change.

if you use static data (shared across threads) then you must use locking. in
your example, you need to do some sort of locking, as if two users insert at
the same time, they can both get the id back. you can lock in your aspx code
(not the best), or you can lock at the database level if you are using a
database like db2, sqlserver or oracle, though the techique will be
different for each.

-- bruce (sqlwork.com)


"Andrea" <googlegroups@fuck_the_spam_cleanmail.it> wrote in message
news:9f*************************@news.microsoft.co m...
Suppose a base class like
partial class X : Page ...
and a class A that is called from class X somewhere along the code.

I'm not able to understand if for each user connected to the web site, a
thread is created and so every call to class A stay in different thread or
all works into a single thread.

I'm asking this because I've a function the get the last ID of a table in
the db, but I'm worried about that multiple call can return the same
number at same time (since I just get the number) and after I increment
it.

What could be a solution? In a multiple thread scenario, the lock
statement sounds good ... but I'm not sure about the scenario it
represents.

Thanks
Andrea

Mar 23 '06 #2
Hello Bruce,

Thanks, unfortunately, actually I'm on access, so the only lock I can use
is over asp.net.

But when I'll develop the DL for SQL server, I'll use the lock on the DB.

Bye
Andrea

Mar 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bmatt | last post by:
I am trying to support multiple interpreter instances within a single main application thread. The reason I would like separate interpreters is because objects in my system can be extended with...
1
by: Craig Ringer | last post by:
Hi folks I'm a bit of a newbie here, though I've tried to appropriately research this issue before posting. I've found a lot of questions, a few answers that don't really answer quite what I'm...
5
by: Tommy | last post by:
Just recently, I happened came across one .net multithreading book saying that multithread programs might get differential in stability when running on single CPU machine compared to a multi-CPU...
9
by: MrSpock | last post by:
1. Create a new Windows Application project. 2. Open the project properties and check "Make single instance application". 3. Build. 4. Go to the release folder and run the application. 5. Try to...
6
by: Fred Exley | last post by:
Just trying to understand the basics here. If the OS has just one CPU, what advantage is there in threading? thanks
35
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
2
by: =?Utf-8?B?VGVycnk=?= | last post by:
I have coded multiple select statements in a single stored procedure, and when I execute this procedure on SQL Server Management Express, I correctly get multiple result sets. But, if I try to add...
10
by: crazycooter | last post by:
I found an old thread on this (http://groups.google.com/group/alt.php/ browse_thread/thread/751edb9c723316c4/ea9bf92a9c6b807c?lnk=gst&q=mail() +duplicate&rnum=7#ea9bf92a9c6b807c), but there didnt...
2
by: Smith | last post by:
Hello, We have a VB6 dll that we need to use in our asp.net 2.0 app. We build it as multiple user. But at runtime, it does not seem to allow more then two pages using the dll at the same time. ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.