Spawn threads from webservice

A

Antonio Iglesias

I have a webservice that has to make a heavy calculation. We want to use
all the processors the machine has. We have built a multithreaded lib that
will do the calculation. When debugging in a regular exe everything works
fine. But when I call the lib from the webservice, although it works, after
finishing the calculation the threads don't seem to join the current
process. They seem to stay. If I try to debug again I can still see the
threads of the last calculation, and after the 3rd calc, I can see 3 sets of
threads (the whole thread pool is kept).

Is it advisable to spawn new threads from dlls running under IIS?? If it
is, how should I do it so that they will interact happily with IIS?

Regards,

Antonio.
 
D

Dale

How about having IIS call a Windows service or .NET Remoting server? In
that way, you can gain control over the threading.

Dale
 
M

[MSFT]

Hi Antonio,

Is the multithreaded lib a ActiveX DLL or .NET application? How did it
create threads?

Luke
 
A

Antonio Iglesias

Hi Luke,

It's a .NET lib.

It creates threads with New Thread like:
---------------------------------------------------------------
MyThreadPool(i) = New Thread(AdrressOf ThreadFunction)
....
MyThreadPool(i).Start
....
MyThreadPool(i).Interrupt
MyThreadPool(i).Join
 
M

[MSFT]

Hi Antonio,

The IIS application thread belongs to the managed thread pool. It may not
get terminated after the Response is sent. I suggest you may add a paramter
to the Join method of your Threads, so that the thread can .be terminated
after the specified time elapses.

Luke
 
A

Antonio Iglesias

I am using my own thread pool, just to keep it simple. Do you think these
threads would get recycled properly if I used the framework's ThreadPool
Class?
My Thread pool is working fine outside of IIS...

Regards,

Antonio.
 
M

[MSFT]

Hi Antonio,

I think your threads are blocked by the Join methods. The IIS application
thread belongs to the managed thread pool. It may not get terminated after
the Response is sent. I suggest you may add a paramter to the Join method
of your Threads, so that the thread can .be terminated after the specified
time elapses.

If you have any concerns/questions, please feel free to let me know.

Luke
 

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,780
Messages
2,569,609
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top