I don't know how to title this thread, forgive me if it's bad.
I'm trying to determine the best way of handling this and I'm getting nervous about it.
The basic setup I have is a server system that is run when the application is open (it's not a service, but a winforms app). The server form shows (among other things) a button to start and stop the server, and a rich text box showing the activity of the server and the clients connected to it.
Standard modeling for something like this (I think) suggests 3 layers. A UX layer(or GUI layer for you old farts), a logic layer (the methods used to interact with the data...the core of the server really), and the data layer (in this case a SQL server).
In my situation, the UX is a win form app, the logic is a dll which bridges the UX layer to the data layer.
Since each connection to the server will run on its own thread, what is the best way for those threaded connection instances to access the logic layer to update, delete, get data etc...basically "talk" to the server? I was going to put on my UX form a static instance of the logic layer (the dll) and just have the threads use that, but I'm worried that if I do that, the UX layer will "hang" while methods are called from it. That can't happen.
So I guess the nutshell question is, if I do this on the UX form:
private static MyServer.LogicLayer _MyLogic = new MyServer.LogicLayer();
public MyServer.LogicLayer MyLogic
{
get { return _MyLogic; }
}
and a different thread (that was started by the UX form thread) does something like this:
DataSet MyDataSet = UxForm.MyLogic.MyServerMethod();
is the whole world going to fall apart? Errr...I mean, will the server form hang if it takes a while for the method to finish (also there could be multiple calls from multiple threads to the same method!) I just can't see creating an instance of the MyServer.LogicLayer on each new thread...maybe I need to?
Please...I need suggestions.