We have a business rule built in VB that uses an MVC layout. We have need of certain variables throughout the different functions/subs at any given moment, so we made a class similar to this:
Public Class PublicVariables
Public Shared itemID As String
Public Shared FLD01 As String
Public Shared FLD02 As String
Public Shared FLD03 As String
Public Shared FLD04 As String
Public Shared FLD05 As String
Public Shared FLD06 As String
Public Shared FLD07 As String
Public Shared FLD08 As String
Public Shared FLD09 As String
Public Shared FLD10 As String
End Class
The problem is that if two people run this business rule at the same time, it appears that the public variables are being reused. For example, if one person triggers the rule under itemID ABC123 and a different person triggers the rule under itemID DEF456, the second person will actually be using the itemID ABC123 because the public variable for itemID still holds that value (even though it is running a different instance of the rule). I tried clearing all variables at the beginning of the code. I've also tried instantiating a new PublicVariables object at the beginning of the code and just reference the variables that way, but now I'm running into this issue when trying to go that route: https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/error-messages/bc42025
Is there any way to get around this issue, but still have the ability to use the public variables?