Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2005

Tip: Looking for answers? Try searching our database.

BackgroundWorker vs. _beginthread

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JHoletzeck - 01 Jun 2005 16:47 GMT
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
William DePalo [MVP VC++] - 01 Jun 2005 19:36 GMT
> 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/default.asp?url=/library/en-us/vccore/html/_co
re_.2f.stack_linker.asp


for the linker option

and here

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


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

Regards.
Will
William DePalo [MVP VC++] - 01 Jun 2005 19:54 GMT
>> Is it possible to set the stack size for the thread created by
>> BackgroundWorker like in the API call _beginthread?
>
> No.

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
Willy Denoyette [MVP] - 02 Jun 2005 20:50 GMT
> 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
[quoted text clipped - 6 lines]
> 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.
Marcus Heege - 02 Jun 2005 21:43 GMT
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.

>> 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
[quoted text clipped - 16 lines]
> int maxStackSize
> );Willy.
Willy Denoyette [MVP] - 03 Jun 2005 00:02 GMT
> 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.