At Delphi, I implemented a very close software solution for complex biological analysis.
I see at least two implementation patterns:
1 - You can use the same Delphi executable file at the same time:
- Background service application
- GUI application.
Keep in mind that in this case two instances of the executable file will be executed. Thus, you cannot easily share variables between two pieces of code, they will have to rely on some IPC mechanism: GDI messages are light and fast, but not allowed with Vista for the service application, so I assume that the named pipe will be the right candidate.
Advantage: part of the service will be executed in the background, even before the user opens a Windows session (this makes sense for the background task).
Disadvantage: more complex IPC to implement.
But if you make the IPC network ready, you can remotely consult all your data: you can install the client application on the network, even if it is necessary on the Internet. Or you can deploy the Ajax application if you use publication, for example. some JSON or HTML content over HTTP.
(I used this project for my automated device with HTTP / 1.1 Client-Server ORM to share the same classes between client and server).
2 - You can have one Delphi executable file simultaneously with a background application and a graphical interface.
To implement this:
- Overwrite the
OnClose / wmClose
event to prevent the form from closing; instead minimize it in the tray; - Create a semaphore to localize an existing application: therefore, when you start another .exe time, it restores the main application;
- The tray icon will have a menu or restore the application by double-clicking;
- Create a background thread to handle all measures - use a loop with a
Sleep
call.
source share