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(AddressO f TheThreadProc)
ttt.ApartmentSt ate = Threading.Apart mentState.STA
ttt.Start()
ttt.Join()
And the simple thread:
Private Sub TheThreadProc()
Dim iii As Integer = 10
End Sub 5 1359
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******** ******@TK2MSFTN GP14.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(AddressO f TheThreadProc) ttt.ApartmentSt ate = Threading.Apart mentState.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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:uh******** ******@TK2MSFTN GP15.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******** ******@TK2MSFTN GP14.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(AddressO f TheThreadProc) ttt.ApartmentSt ate = Threading.Apart mentState.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******** *****@TK2MSFTNG P09.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***@DIESPAMM ERSDIEtakempis. com> wrote in message news:uh******** ******@TK2MSFTN GP15.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******** ******@TK2MSFTN GP14.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(AddressO f TheThreadProc) ttt.ApartmentSt ate = Threading.Apart mentState.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******** *****@TK2MSFTNG P09.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***@DIESPAMM ERSDIEtakempis. com> wrote in message news:uh******** ******@TK2MSFTN GP15.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******** ******@TK2MSFTN GP14.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(AddressO f TheThreadProc) ttt.ApartmentSt ate = Threading.Apart mentState.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 threads, however their run methods
are never called. Interestingly enough, threading.activeCount() and
threading.enumerate() properly return all the threads I've started. Yet
none of them will get their run method called.
The python...
|
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 used WM_USER based messages to
communicate status from the worker thread back to the UI thread. What is
the right way to do this in .Net? Are asynchronous delegates the way to go,
or is there a better (or just different) approach I should...
|
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 component becomes instabile, throwing a
Windows like error (access violation on 0x00000002), not an framework
exception. The component and all of its subcomponents are 100% managed code.
What could go wrong with Thread.Abort()?
Thanks for any hints.
|
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?). Global.asax.cs creates it in
Application_Start, initializes it and places it in the cache. During
initialization, CacheLogic retrieves data from the DB logic layer and caches
it with removal callbacks set. Whenever an object in the business logic
layer...
|
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 can drill down into the process, and
get the offending Thread's ID (since the only ones that will have the issue
have higher User processor Time).
But, I can't figure out how to have my .Net app 'kill' or 'suspend' a Thread
| |
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 dynamically allocated objects
using smart pointer. The reference to the shared object is 2. If one
thread crashes before decreasing the reference, then eventually the
reference will still be 1, so the object will not be deleted. So this
|
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 "Stack Reserver Size" in
Properties->ConfigurationsProperties->Linker->System is increased, the memory
leak grows up to 10MB and more dependent on the stack reserve size.
|
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 with weirdness going on with
the server I am talking to. Anyhow, this locked up state happens once in a
while (maybe once per day) and I can't figure out how to deal with the locked
up thread.
If I issue a Thread.Abort() the exception never...
|
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 less. When the
task is completed, there are somewhere between 4 and 7 handles still
open.
My process is loading images and shrinking them down. I went through
all the code and found some objects that implement the IDisposable
interface which I...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |