I am creating a worker thread from inside an aspx page and the thread does
the stuff it should do, no problem.
However, I have noticed running it in the debugger that it seems as if the
threads are not killed/garbage-collected after a thread terminates. I have a
breakpoint in the thread itself and every time it breaks, in the Threads
window I observe the new thread, but the previous thread is still there as
well. The exact same code in a windows app performs as expected, on every
break there are two threads, the main thread and the current worker thread.
The simplified code below also gives the same results, so nothing strange in
the thread itself. If I put the code in a loop of 2000 cycles and break
after the last, then there are 2000 worker threads displayed in the Threads
window.
Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
ttt.ApartmentState = Threading.ApartmentState.STA
ttt.Start()
ttt.Join()
And the simple thread:
Private Sub TheThreadProc()
Dim iii As Integer = 10
End Sub 5 1328
This is because you are using a Single-Threaded Apartment. There is nothing
in the thread to receive messages. When you use COM in an ASP.Net
application, you create an Interop class that is disposable, and therefore,
the thread can be killed. IOW, don't use an STA thread unless you are doing
Interop.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.
"Chris Botha" <ch***********@AThotmail.com> wrote in message
news:uo**************@TK2MSFTNGP14.phx.gbl... I am creating a worker thread from inside an aspx page and the thread does the stuff it should do, no problem. However, I have noticed running it in the debugger that it seems as if the threads are not killed/garbage-collected after a thread terminates. I have a breakpoint in the thread itself and every time it breaks, in the Threads window I observe the new thread, but the previous thread is still there as well. The exact same code in a windows app performs as expected, on every break there are two threads, the main thread and the current worker thread. The simplified code below also gives the same results, so nothing strange in the thread itself. If I put the code in a loop of 2000 cycles and break after the last, then there are 2000 worker threads displayed in the Threads window.
Dim ttt As Thread = New Thread(AddressOf TheThreadProc) ttt.ApartmentState = Threading.ApartmentState.STA ttt.Start() ttt.Join()
And the simple thread:
Private Sub TheThreadProc() Dim iii As Integer = 10 End Sub
Kevin, thanks for the response, however this is not it, I tested it without
STA before I posted the problem, same result.
The true thread is doing Interop, the simple example below is not (the
simple example produces the error/issue, with or without the STA statement).
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl... This is because you are using a Single-Threaded Apartment. There is nothing in the thread to receive messages. When you use COM in an ASP.Net application, you create an Interop class that is disposable, and therefore, the thread can be killed. IOW, don't use an STA thread unless you are doing Interop.
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer Everybody picks their nose, But some people are better at hiding it.
"Chris Botha" <ch***********@AThotmail.com> wrote in message news:uo**************@TK2MSFTNGP14.phx.gbl...I am creating a worker thread from inside an aspx page and the thread does the stuff it should do, no problem. However, I have noticed running it in the debugger that it seems as if the threads are not killed/garbage-collected after a thread terminates. I have a breakpoint in the thread itself and every time it breaks, in the Threads window I observe the new thread, but the previous thread is still there as well. The exact same code in a windows app performs as expected, on every break there are two threads, the main thread and the current worker thread. The simplified code below also gives the same results, so nothing strange in the thread itself. If I put the code in a loop of 2000 cycles and break after the last, then there are 2000 worker threads displayed in the Threads window.
Dim ttt As Thread = New Thread(AddressOf TheThreadProc) ttt.ApartmentState = Threading.ApartmentState.STA ttt.Start() ttt.Join()
And the simple thread:
Private Sub TheThreadProc() Dim iii As Integer = 10 End Sub
Are you setting the "aspcompat" attribute?
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.
"Chris Botha" <ch***********@AThotmail.com> wrote in message
news:Oq*************@TK2MSFTNGP09.phx.gbl... Kevin, thanks for the response, however this is not it, I tested it without STA before I posted the problem, same result. The true thread is doing Interop, the simple example below is not (the simple example produces the error/issue, with or without the STA statement).
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message news:uh**************@TK2MSFTNGP15.phx.gbl... This is because you are using a Single-Threaded Apartment. There is nothing in the thread to receive messages. When you use COM in an ASP.Net application, you create an Interop class that is disposable, and therefore, the thread can be killed. IOW, don't use an STA thread unless you are doing Interop.
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer Everybody picks their nose, But some people are better at hiding it.
"Chris Botha" <ch***********@AThotmail.com> wrote in message news:uo**************@TK2MSFTNGP14.phx.gbl...I am creating a worker thread from inside an aspx page and the thread does the stuff it should do, no problem. However, I have noticed running it in the debugger that it seems as if the threads are not killed/garbage-collected after a thread terminates. I have a breakpoint in the thread itself and every time it breaks, in the Threads window I observe the new thread, but the previous thread is still there as well. The exact same code in a windows app performs as expected, on every break there are two threads, the main thread and the current worker thread. The simplified code below also gives the same results, so nothing strange in the thread itself. If I put the code in a loop of 2000 cycles and break after the last, then there are 2000 worker threads displayed in the Threads window.
Dim ttt As Thread = New Thread(AddressOf TheThreadProc) ttt.ApartmentState = Threading.ApartmentState.STA ttt.Start() ttt.Join()
And the simple thread:
Private Sub TheThreadProc() Dim iii As Integer = 10 End Sub
Also, Chris, as you didn't post your actual code, I can't really guess what
the problem is. However, I believe you can find your answers at one or more
of the following MSDN articles (and related links): http://msdn.microsoft.com/library/en...asp?frame=true http://msdn.microsoft.com/library/en...asp?frame=true
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.
"Chris Botha" <ch***********@AThotmail.com> wrote in message
news:Oq*************@TK2MSFTNGP09.phx.gbl... Kevin, thanks for the response, however this is not it, I tested it without STA before I posted the problem, same result. The true thread is doing Interop, the simple example below is not (the simple example produces the error/issue, with or without the STA statement).
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message news:uh**************@TK2MSFTNGP15.phx.gbl... This is because you are using a Single-Threaded Apartment. There is nothing in the thread to receive messages. When you use COM in an ASP.Net application, you create an Interop class that is disposable, and therefore, the thread can be killed. IOW, don't use an STA thread unless you are doing Interop.
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer Everybody picks their nose, But some people are better at hiding it.
"Chris Botha" <ch***********@AThotmail.com> wrote in message news:uo**************@TK2MSFTNGP14.phx.gbl...I am creating a worker thread from inside an aspx page and the thread does the stuff it should do, no problem. However, I have noticed running it in the debugger that it seems as if the threads are not killed/garbage-collected after a thread terminates. I have a breakpoint in the thread itself and every time it breaks, in the Threads window I observe the new thread, but the previous thread is still there as well. The exact same code in a windows app performs as expected, on every break there are two threads, the main thread and the current worker thread. The simplified code below also gives the same results, so nothing strange in the thread itself. If I put the code in a loop of 2000 cycles and break after the last, then there are 2000 worker threads displayed in the Threads window.
Dim ttt As Thread = New Thread(AddressOf TheThreadProc) ttt.ApartmentState = Threading.ApartmentState.STA ttt.Start() ttt.Join()
And the simple thread:
Private Sub TheThreadProc() Dim iii As Integer = 10 End Sub
worker threads should be terminated, as you showed code of one
statement.
There would be 2000 (caller) main threads waiting for worker to be
terminated.
If you are saying worker thread (small one statement proc) is not
terminating (GC)
then Caller threads must also be alive.
Check ttt.IsAlive and do ttt.Abort() and ttt = Nothing
and test.
The (worker thread) code is being called by pageclass which is also
generated by some other asp.net parent thread (if that is calling abort
or someother stuff on the thread of pageclass this could affect).
Do let us know of your proceedings.
---
hB This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Humphreys, Brett |
last post by:
Hello All,
To preface my question, I'm running python on an embedded PowerPC chip
(8xx), with a host OS of Linux. I'm seeing, in some of my applications,
thread starvation. I can create new...
|
by: Brett Robichaud |
last post by:
I'm trying to decide on the right approach for communication between the UI
and a worker thread in a WinForms app. I am very familiar with threads in
the unmanaged C++ world and in the past have...
|
by: Urs Vogel |
last post by:
Hi
I wrote an application server (a remoting sinlgeton), where processes must
be stopped in very rare cases, done thru a Thread.Abort(). Occasionally, and
only after a Thread.Abort(), this...
|
by: William Sullivan |
last post by:
I'm trying to nail down some issues with the cache in my application.
Currently, I have an object that stands between my business logic and
database logic called CacheLogic (cute, no?). ...
|
by: Rob |
last post by:
Hello,
I've got an issue where a process in a third party application has a dll
which while exiting sort of freezes and runs away with processor cycles.
i've written a block of code so that I...
|
by: Jack |
last post by:
Hi,
In multi-thread programming, if I using smart pointers to store
pointers to the same dynamically allocated objects, can memory leak be
avoided?
For example, two threads share the same...
|
by: =?Utf-8?B?SGFubmVzIFN0ZWlua2U=?= |
last post by:
Hello,
I'm trying to use the command "#pragma omp parallel for" within a thread but
each thread that is created (and stopped again) produces a memory leak of
about 44kB.
If the entry for...
|
by: =?Utf-8?B?VGhlU2lsdmVySGFtbWVy?= |
last post by:
Because C# has no native SSH class, I am using SharpSSH. Sometimes, for
reasons I do not know, a Connect call will totally lock up the thread and
never return. I am sure it has something to do...
|
by: Cartoper |
last post by:
My application appears to have a recourse leak. When the user starts
a background process, the handle count in Process Explorer (PE) goes
up by about 10, sometime 1 or 2 more, sometimes 1 or 2...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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: 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...
|
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,...
| |