473,796 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BackgroundWorke r vs. _beginthread

Is it possible to set the stack size for the thread created by
BackgroundWorke r 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
Nov 17 '05 #1
5 2229
"JHoletzeck " <JH********@dis cussions.micros oft.com> wrote in message
news:2F******** *************** ***********@mic rosoft.com...
Is it possible to set the stack size for the thread created by
BackgroundWorke r 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/de...ack_linker.asp

for the linker option

and here

http://msdn.microsoft.com/library/de..._STACKSIZE.asp

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

Regards.
Will
Nov 17 '05 #2
"William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
"JHoletzeck " <JH********@dis cussions.micros oft.com> wrote in message
news:2F******** *************** ***********@mic rosoft.com...
Is it possible to set the stack size for the thread created by
BackgroundWorke r 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, BackgroundWorke r 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
Nov 17 '05 #3

"JHoletzeck " <JH********@dis cussions.micros oft.com> wrote in message
news:2F******** *************** ***********@mic rosoft.com...
Is it possible to set the stack size for the thread created by
BackgroundWorke r 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.

Nov 17 '05 #4
Backgroundworke r 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.
"Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
news:uG******** ******@TK2MSFTN GP12.phx.gbl...

"JHoletzeck " <JH********@dis cussions.micros oft.com> wrote in message
news:2F******** *************** ***********@mic rosoft.com...
Is it possible to set the stack size for the thread created by
BackgroundWorke r 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.

Nov 17 '05 #5

"Marcus Heege" <NO****@heege.n et> wrote in message
news:eN******** ******@TK2MSFTN GP10.phx.gbl...
Backgroundworke r 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.
Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1899
by: dude | last post by:
I am trying to test out _beginthread() but I keep getting an error that: _beginthread : undeclared identifier I am using Visuall C++ with DotNET Studio and am on windows XP. Here is the full program: *******************************************************************
2
2903
by: Altman | last post by:
I have a class called cScale, I have made an array of scale objects and I need to run a method of these objects as a new thread. This is my line of code and I can't get it to run. I am still a little of a newbie to C++. Scales is an array of scale objects and weighup is my method. Scales.thread = _beginthread( Scales.WeighUp, 0, NULL);
3
4309
by: shell6 | last post by:
I get a few errors building a prog with _beginthread. I have done the proper compile options and included libcmt.lib in linking, but I still get these errors: libcimtd.lib(streamb.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int,int,char const *,int)" (??2@YAPAXIHPBDH@Z) libcimtd.lib(iostrini.obj) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int,int,char...
5
14134
by: Rob R. Ainscough | last post by:
I'm using a BackgroundWorker to perform a file download from an ftp site. Per good code design practices where I separate my UI code from my core logic code (in this case my Download file method in my FileIO class) I've established Public Event in my core logic classes along with RaiseEvents (that will updated a progress bar on the UI side). This all works great when I'm NOT using Threading (BackgroundWorker), however, as soon as I...
1
3235
by: Bob | last post by:
Hi, I am having trouble seeing how this bolts together. The UI starts a process which involves a long running database update. All Database activity is handled by a class called DT. DT has a progress event. So I added a bw to the form. The Dowork Calls a method which instantiates a DT and calls its Dataprocessing method.
14
6396
by: =?Utf-8?B?SXNobWFlbA==?= | last post by:
Hi, I have a form with a progress bar on it and wanted to use the BackgroundWorker to be able to update the progress. I looked at examples, run some of them, but in debug, when the code gets to the do work method, it stops for a long while and then executes the first line of the method and the doesn't do anything else. What am i doing wrong?
0
2482
by: Chris | last post by:
I would like to be able to pass the BackgroundWorker object and DoWork Event Args to a second function (third function?) and be able to still report the progress. I'm getting the following exception when trying to access BackgroundWorker.CancellationPending or e.Cancel An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll Additional information: Exception has been thrown by the target of...
2
4839
by: Chris | last post by:
When I try to access the backgroundWorker.CancellationPending property I get the following exception: An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll Additional information: Exception has been thrown by the target of an invocation. I am using the backgroundWorker in a component that I am trying to make for doing encryption of large files in the background.
9
18036
by: RvGrah | last post by:
I'm completely new to using background threading, though I have downloaded and run through several samples and understood how they worked. My question is: I have an app whose primary form will almost always lead to the user opening a certain child window that's fairly resource intensive to load. Is it possible to load this form in a backgroundworker and then use the Show method and hide method as necessary? Anyone know of
0
9685
marktang
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...
0
9533
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,...
0
10461
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10019
tracyyun
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...
1
7555
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5447
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.