Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

are there potential pitfalls to using static methods in a web application (.net)?

From the web app, calls are made to a web service that in turn makes calls to a few static helper classes for filtering and sorting data - trying to think ahead if I will have unexpected behavior with multiple users

like image 710
Pete_ch Avatar asked Jan 20 '26 23:01

Pete_ch


1 Answers

Make sure your static methods are thread-safe.

Thread safety fundamentally deals with ensuring that two threads don't access a shared resource in a conflicting manner.

There's a great overview on Wikipedia.

The best tutorial I have ever found about threading in the .NET environment is by Joe Albahari.

like image 92
Eric J. Avatar answered Jan 23 '26 15:01

Eric J.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!