Without seeing the actual code for GetFirstRequest
and GetSecondRequest
, we can't tell - but the fact that you've got an instance variable of type StringBuilder
makes me skeptical. StringBuilder
itself isn't thread-safe, and if you're modifying a single object in multiple threads I doubt that you'll get the result you want anyway.
If you're using StringBuilder
to build a complete URL, why not just create that StringBuilder
in each method? If you don't need to change any of the state of your object, you'll be a long way towards being thread-safe.
Also note that your method has a params
parameter but could also access the params
instance variable (which would need a different name anyway as params
is a keyword in C#). Do you really need that duplication? Why not just use the instance variable from the method?
It feels like this class can be made thread-safe, but almost certainly isn't yet. You need to design it to be thread-safe - which means either avoiding any state mutation, or using appropriate locking. (The former approach is usually cleaner where it's possible.)