BackgroundWorker vs. _beginthread

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to set the stack size for the thread created by
BackgroundWorker like in the API call _beginthread? If not is the stack size
a default or the one I set for the whole application?
(What I need is a worker thread with a rather large stack in a Windows Forms
app complied with /clr:pure)

Cheers
Jürgen
 
JHoletzeck said:
Is it possible to set the stack size for the thread created by
BackgroundWorker like in the API call _beginthread?
No.

If not is the stack size a default or the one I set for the whole
application?

The latter. See here

http://msdn.microsoft.com/library/d.../en-us/vccore/html/_core_.2f.stack_linker.asp

for the linker option

and here

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_STACKSIZE.asp

for the equivalent module definition file option. Note that either only has
a bearing on executables.

Regards.
Will
 
William DePalo said:

I may have misinterpreted your question. The question I _thought_ you were
asking is "Is it possible to set the stack size for threads I create at
runtime?". The answer to that question for native applications is no as I
wrote. The total size of the address space to be occupied by the stack is
set a link time. The parameter passed to beginthreadex() is just the subset
of that region which is initially committed. The stack will grow dynamically
from its initially committed size to the size reserved at link time.

If, though, BackgroundWorker refers to some thread class which I don't see
the MSDN index, then please post again with more details as to the class.

Regards,
Will
 
JHoletzeck said:
Is it possible to set the stack size for the thread created by
BackgroundWorker like in the API call _beginthread? If not is the stack
size
a default or the one I set for the whole application?
(What I need is a worker thread with a rather large stack in a Windows
Forms
app complied with /clr:pure)

Cheers
Jürgen

Background worker (Framework v2.0) uses a default stack size of 1MB and
there is no way to change it, but the Thread class has a contructor overload
that takes the stack size as argument.

public:
Thread(
ThreadStart^ start,
int maxStackSize
);Willy.
 
Backgroundworker uses the CLR thread pool. In theory it is possible to
influence theads in the CLR thread pool using the custom CLR hosting APIs,
but you will rearely want to do this.
 
Marcus Heege said:
Backgroundworker uses the CLR thread pool. In theory it is possible to
influence theads in the CLR thread pool using the custom CLR hosting APIs,
but you will rearely want to do this.

I don't see any possibility to change the stack size of the CLR threadpool
threads using the hosting API's.
Only thing that can be done is setting the stacksize for tasks attributed to
fibers in v2.0. I'm I missing something?

Willy.
 
Back
Top