The controller is the heart of ScanMaster. The application is built around this controller, which gets the execution thread early on in application startup (look at the Main method in Runner). The controller is a singleton (there is only ever one controller). And I really mean only one - as in there is only ever one running on the machine. There are two ways to get hold of a reference to the controller object. If you are in the same (local) context that the Controller was instantiated in (which means, almost certainly, that you are writing code that is part of ScanMaster) then you should use the static factory method Controller.GetController(). If you are outside the Controller's context (which means you are probably writing another application that wants to use ScanMaster's services) then you should get hold of an object reference through the remoting system. You might well do this by registering the Controller type as well known within your application and then using new to to get a reference, but you shouldn't forget that you're actually dealing with a singleton ! The controller is published at "tcp://localhost:1170/controller.rem". The controller inherits from MarshalByRefObject so that references to it can be passed around by the remoting system.
Inheritance: System.MarshalByRefObject
Exemplo n.º 1
0
 // This is the right way to get a reference to the controller. You shouldn't create a
 // controller yourself.
 public static Controller GetController()
 {
     if (controllerInstance == null)
     {
         controllerInstance = new Controller();
     }
     return controllerInstance;
 }