Need an advice with this (multithread)

G

Guest

Hi I need some advice about this situation an how I'm current handling it

I hava a ASP.NET solution that in some point start multiples lenghty
verification agains diferent databases, my big challenge is that the user
click in a button "start process"
and close the explorer windows... and in the backgroud all the required
query are executed, when the user is back, maybe two hours late the process
is finish ..

I currently hadlle this (in a developing enviroment) creating a thread when
the user click the star button and this thread start some news thread for
other operation, and seems to work fine,

I create the thread using just this:

Dim thrMyThread As New System.Threading.Thread(AddressOf ExecuteAfter)

Is this ok?
 
A

Alvin Bruney [MVP]

I suggest you have ASP.NET launch an EXE to do this or queue up a windows
launch another process implicitly uses a thread so there is no gain here, in
fact there is more overhead with launching a process than firing a thread to
do the long running query.
It's ok up to the point where the number of users using the application is
low, otherwise you run the risk of spawning too many threads.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
 
S

Steve C. Orr [MVP, MCSD]

ASP.NET threads that run for too long (hours) tend to get orphaned and could
be collected by the garbage collector before they've completed. An EXE is
its own process so I believe it does not have this risk. Windows Services
are also not at risk. This is a matter of using the right tool for the job,
and ASP.NET is not it (in this case.)




Alvin Bruney said:
I suggest you have ASP.NET launch an EXE to do this or queue up a windows
launch another process implicitly uses a thread so there is no gain here,
in fact there is more overhead with launching a process than firing a
thread to do the long running query.
It's ok up to the point where the number of users using the application is
low, otherwise you run the risk of spawning too many threads.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------


Steve C. Orr said:
ASP.NET was not meant for such lengthy operations.
I suggest you have ASP.NET launch an EXE to do this or queue up a windows
service to handle the task. Perhaps a flag can be set in a database when
the process is complete.

Here's more information on Windows Services:
http://msdn.microsoft.com/library/d...nvssamp/html/vbcs_CreatingaWindowsService.asp
 
A

Alvin Bruney [MVP]

ASP.NET threads that run for too long (hours) tend to get orphaned and
could be collected by the garbage collector before they've completed.
You are saying that a running thread with live references can be garbage
collected? That is contrary to the garbage collector algorithm, care to
provide an example, or documentation on this?
This is a matter of using the right tool for the job, and ASP.NET is not it
(in this case.)
I agree.
--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------


Steve C. Orr said:
ASP.NET threads that run for too long (hours) tend to get orphaned and
could be collected by the garbage collector before they've completed. An
EXE is its own process so I believe it does not have this risk. Windows
Services are also not at risk. This is a matter of using the right tool
for the job, and ASP.NET is not it (in this case.)




Alvin Bruney said:
I suggest you have ASP.NET launch an EXE to do this or queue up a
windows
launch another process implicitly uses a thread so there is no gain here,
in fact there is more overhead with launching a process than firing a
thread to do the long running query.
Is this ok?
It's ok up to the point where the number of users using the application
is low, otherwise you run the risk of spawning too many threads.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------


Steve C. Orr said:
ASP.NET was not meant for such lengthy operations.
I suggest you have ASP.NET launch an EXE to do this or queue up a
windows service to handle the task. Perhaps a flag can be set in a
database when the process is complete.

Here's more information on Windows Services:
http://msdn.microsoft.com/library/d...nvssamp/html/vbcs_CreatingaWindowsService.asp





Hi I need some advice about this situation an how I'm current handling
it

I hava a ASP.NET solution that in some point start multiples lenghty
verification agains diferent databases, my big challenge is that the
user
click in a button "start process"
and close the explorer windows... and in the backgroud all the required
query are executed, when the user is back, maybe two hours late the
process
is finish ..

I currently hadlle this (in a developing enviroment) creating a thread
when
the user click the star button and this thread start some news thread
for
other operation, and seems to work fine,

I create the thread using just this:

Dim thrMyThread As New System.Threading.Thread(AddressOf ExecuteAfter)

Is this ok?
 
S

Steve C. Orr [MVP, MCSD]

A page request owns the thread.
A page request will time-out eventually, orphaning the thread.
I don't have any documentation handy but there was a long discussion on this
topic a while back in here...




Alvin Bruney said:
ASP.NET threads that run for too long (hours) tend to get orphaned and
could be collected by the garbage collector before they've completed.
You are saying that a running thread with live references can be garbage
collected? That is contrary to the garbage collector algorithm, care to
provide an example, or documentation on this?
This is a matter of using the right tool for the job, and ASP.NET is not
it (in this case.)
I agree.
--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------


Steve C. Orr said:
ASP.NET threads that run for too long (hours) tend to get orphaned and
could be collected by the garbage collector before they've completed. An
EXE is its own process so I believe it does not have this risk. Windows
Services are also not at risk. This is a matter of using the right tool
for the job, and ASP.NET is not it (in this case.)




Alvin Bruney said:
I suggest you have ASP.NET launch an EXE to do this or queue up a
windows
launch another process implicitly uses a thread so there is no gain
here, in fact there is more overhead with launching a process than
firing a thread to do the long running query.

Is this ok?
It's ok up to the point where the number of users using the application
is low, otherwise you run the risk of spawning too many threads.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------


ASP.NET was not meant for such lengthy operations.
I suggest you have ASP.NET launch an EXE to do this or queue up a
windows service to handle the task. Perhaps a flag can be set in a
database when the process is complete.

Here's more information on Windows Services:
http://msdn.microsoft.com/library/d...nvssamp/html/vbcs_CreatingaWindowsService.asp





Hi I need some advice about this situation an how I'm current handling
it

I hava a ASP.NET solution that in some point start multiples lenghty
verification agains diferent databases, my big challenge is that the
user
click in a button "start process"
and close the explorer windows... and in the backgroud all the
required
query are executed, when the user is back, maybe two hours late the
process
is finish ..

I currently hadlle this (in a developing enviroment) creating a thread
when
the user click the star button and this thread start some news thread
for
other operation, and seems to work fine,

I create the thread using just this:

Dim thrMyThread As New System.Threading.Thread(AddressOf ExecuteAfter)

Is this ok?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top