Thread constructor - maxStackSize argument?

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

Guest

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
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
 
That makes sense.

Thanks a bunch Mattias!

Mattias Sjögren said:
I believe it's in bytes.



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
 
TMcM said:
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?

The documentation says to avoid using it.

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.
 
Back
Top