I have created a library which is using threadstatic variables to be used by various classes of the same library. Once initialized for a thread, all these classes work together to achieve a task using these variables.
Now i need to use this same library in an ASP.NET application and i have come to know that threadstatic won't make my variables global for a single thread but these will be shared across threads.
I am avoiding passing variables to functions because it does not sound good approach. So I need a solution to make my library usable for both type of applications (winforms + webforms) i.e. an alternate for threadstatic and session.
How about implementing my own management using dictionary in the library? Knowing who has called me (library) i.e. desktop application or asp.net and after that using thread id or session id respectively to grab variables from the dictionary. Right now, i don't know whether it is possible or not.
And what if a web service is created for this library which will be hosted by an exe instead of IIS to avoid thread sharing by ASP.NET causing threadstatic to malfunction ?
Please suggest a solution.