.NET Framework Developer Center >
.NET Development Forums
>
.NET Remoting and Runtime Serialization
>
Two threads, One Method
Two threads, One Method
- Hi Guys.
I'm working in VS 2008 C# and C# CF
I have a method with a String parameter and returning an encoded string.
If I have two threads which call this method, and at some point they call the method at the same time with two different parameters. Will this infuence the returned result of the method to each thread individually, or will I have to do something else to synchronize/join the threads?
Thank you....
Answers
Hi Guys.
I'm working in VS 2008 C# and C# CF
I have a method with a String parameter and returning an encoded string.
If I have two threads which call this method, and at some point they call the method at the same time with two different parameters. Will this infuence the returned result of the method to each thread individually, or will I have to do something else to synchronize/join the threads?
Thank you....
A method that can be active by two or more execution threads at once, is called "reentrant" and is entirely valid and normal in computing.
In order to work reliably in such a way that no executiin thread impacts any other, some rules must be followed, see this article.
If your code simply manipulates a supplied argument and uses only local (stack) variables in doing so, then it will be fine.
You only need to worry of any of the data accessed (directly or indirectly) by the code is shared or shreable, if not, then all is well.
Does that help?
Hugh
Hugh Moran - http://www.morantex.com- Marked As Answer byBramenator Tuesday, November 10, 2009 5:37 AM
All Replies
Hi Guys.
I'm working in VS 2008 C# and C# CF
I have a method with a String parameter and returning an encoded string.
If I have two threads which call this method, and at some point they call the method at the same time with two different parameters. Will this infuence the returned result of the method to each thread individually, or will I have to do something else to synchronize/join the threads?
Thank you....
A method that can be active by two or more execution threads at once, is called "reentrant" and is entirely valid and normal in computing.
In order to work reliably in such a way that no executiin thread impacts any other, some rules must be followed, see this article.
If your code simply manipulates a supplied argument and uses only local (stack) variables in doing so, then it will be fine.
You only need to worry of any of the data accessed (directly or indirectly) by the code is shared or shreable, if not, then all is well.
Does that help?
Hugh
Hugh Moran - http://www.morantex.com- Marked As Answer byBramenator Tuesday, November 10, 2009 5:37 AM


