I am creating a stock and inventory program for a wholesaler in C# windows forms, i have a product search form that allows me to search for a product and returns the productID,Name And price, which i use in many different forms. Currently i am saving the ProductID, Name and Price in static variables in a Utility class which i read the data back from. I use the same Product Search Form in various screen, e.g. Invoicing Screen, Orders Screen, Stock Receiving screen etc. Everything works fine but i now want to make the program multi user and i am not sure how my method will affect a multiuser environment. I have done alot of research but have not found any clear answers. Everyone says global variables are bad but dont say clearly how to achieve what i want clearly.
I want one Product search form that i can call on from different screens and get the data back to the calling screen safely without another user on the network changing the data before i can use it.
I have tried creating a private class and instantiating the class whenever i want to use it, but my confusion is, “How do i pass data from one instance of a class back to another instance of the same class on two different screens” 🙁