Our ticket system vendor provides an .NET API library and I've been trying to make use of this from a multi-threaded application. I'm running into all sorts of connection/stateful issues and I believe this is perhaps because it's not "thread-safe" (I'm still a novice with C# and threaded applications, so just my guess at the moment as some of the symptoms line up).
The API doesn't have a class that is instantiated, you just call the static methods TrebuchetApi.Api.Connect()
and TrebuchetApi.Api.Login()
from it's namespace (in fact all methods appear to be static).
So I maybe have one thread doing one thing, and another doing something else, and the underlying API is getting confused (static variables that should be set are null and such).
Is there any way of making each of my threads use a brand new 'instance' of the API, or is it simply unavoidable?
Update:
For clarity, after the suggestions for using AppDomains I found this article which provided the exact framework I needed: http://www.superstarcoders.com/blogs/posts/executing-code-in-a-separate-application-domain-using-c-sharp.aspx