|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Thread constructor - maxStackSize argument?Framework 2.0
There is a constructor for the System.Threading.Thread class that takes a ThreadStart object and an int as construction arguments. The ThreadStart object is the delegate to the thread entry point obviously, but what is the maxStackSize integer value used for? I can see that it will set the size of the stack, but in what unit of measure? Can anyone give me an example of when/why you would want to set the maxStackSize? Thanks in advance! >I can see that it will set the size of I believe it's in bytes.>the stack, but in what unit of measure? >Can anyone give me an example of when/why you would want to set the If you know that you have a deep recursion that would overflow the>maxStackSize? default stack size, or if you need to store lots of data on the stack. It's not exactly a common thing to do. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. That makes sense.
Thanks a bunch Mattias! Show quote "Mattias Sjögren" wrote: > > >I can see that it will set the size of > >the stack, but in what unit of measure? > > I believe it's in bytes. > > > >Can anyone give me an example of when/why you would want to set the > >maxStackSize? > > If you know that you have a deep recursion that would overflow the > default stack size, or if you need to store lots of data on the stack. > It's not exactly a common thing to do. > > > Mattias > > -- > Mattias Sjögren [C# MVP] mattias @ mvps.org > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com > Please reply only to the newsgroup. >
Show quote
"TMcM" <T***@discussions.microsoft.com> wrote in message The documentation says to avoid using it.news:876C7B31-A35D-473A-97D2-44FDFC47E341@microsoft.com... > Framework 2.0 > > There is a constructor for the System.Threading.Thread class that takes a > ThreadStart object and an int as construction arguments. The ThreadStart > object is the delegate to the thread entry point obviously, but what is > the > maxStackSize integer value used for? I can see that it will set the size > of > the stack, but in what unit of measure? > > Can anyone give me an example of when/why you would want to set the > maxStackSize? This is sounds like good advice since you have no idea how much stack a call to a framework method will take and it's a no brainer that such calls are likely to be the deepest since any method you write will call framework methods. MS could at least have done the tests to come up with a good number. It would probably be morse sensible to specify a minimum stack size for when you know that you are going to do some deep recursion. |
|||||||||||||||||||||||