Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Call Data Module from Windows Service


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: May 12, 2016 2:21 PM Last Post By: Remy Lebeau (Te...
Barry Hickey

Posts: 3
Registered: 4/9/11
Call Data Module from Windows Service  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 12, 2016 2:05 PM
I'm trying to figure out how to load a data module from a Windows service I've written.

The service installs and starts up just fine.

The data module has a timer control with some database code it in that I want to fire off on the timer interval.

How do I get the service to "load" the data module?

FWIW, I'm using Delphi 10 Seattle.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Call Data Module from Windows Service  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 12, 2016 2:21 PM   in response to: Barry Hickey in response to: Barry Hickey
Barry Hickey wrote:
I'm trying to figure out how to load a data module from a Windows service I've written.

The exact same way you do in a non-service application. There is no difference whatsoever in how a DataModule works in a service project versus a non-service project.

The data module has a timer control with some database code it in that I want to fire off on the timer interval.

The TTimer component is a message-based timer. Whatever thread creates the DataModule instance (and thus the TTimer instance) will need a message loop in order to service the timer events. Keep in mind that TService (which is itself a DataModule) is created in the main thread but runs in a worker thread. The main thread and the service thread both have message loops by default, so either one should be capable of handling TTimer events (assuming you are not using the TService.OnExecute event and forgetting to manually pump the service thread message queue periodically). So just pay attention to which thread creates the DataModule, because that is the thread that will receive the timer events.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02