RTC Forums
November 24, 2024, 05:34:32 PM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Help
Login
Register
RTC Forums
>
Subscription
>
Support
>
RTC (win) Service auto-shutdown
Pages: [
1
]
« previous
next »
Print
Author
Topic: RTC (win) Service auto-shutdown (Read 5629 times)
zsleo
RTC Expired
Posts: 80
RTC (win) Service auto-shutdown
«
on:
February 20, 2013, 07:33:48 AM »
I have an app that has been running as a non-service EXE for a few months.
I converted it to run as a Win Service. Still runs perfectly as a non-service EXE but when I start the win-service it shuts down immediately.
I have traced my problem as follows:
I have a TADOConnection in the application and when the Open is called, the database connection starts, logs on successfully then the service stops.
I don't know if it is the RTC or ADO stopping the service.
There are no errors or exceptions being generated - there is a clean log off, disconnect from the MS SQL db (ADO) and stopping of the service.
Any ideas?
TIA
Zane
Logged
zsleo
RTC Expired
Posts: 80
Re: RTC (win) Service auto-shutdown
«
Reply #1 on:
February 20, 2013, 07:38:52 AM »
... just as I sent posted the request I thought I should look at the Event Viewer....
"Service failed on start: CoInitialize has not been called"
Sorry....
Zane
Logged
D.Tkalcec (RTC)
Administrator
Posts: 1881
Re: RTC (win) Service auto-shutdown
«
Reply #2 on:
February 20, 2013, 09:08:56 AM »
Using the rtcActiveX unit somewhere in your Project should fix that problem. The only purpose of that unit is to call "CoInizialize(nil)" for every RTC Thread when the Thread starts and "CoUninitialize" before the Thread stops. These calls are required when using ActiveX components.
Best Regards,
Danijel Tkalcec
Logged
zsleo
RTC Expired
Posts: 80
Re: RTC (win) Service auto-shutdown
«
Reply #3 on:
February 20, 2013, 11:24:46 PM »
Thanks, Danijel.
I should have known there would be an rtcActiveX
I fixed my issue by calling CoInitialize directly and including ActiveX.
Are you saying that if I include the rtcActiveX then I done need to call CoInitialize?
Regards,
Zane
Logged
D.Tkalcec (RTC)
Administrator
Posts: 1881
Re: RTC (win) Service auto-shutdown
«
Reply #4 on:
February 20, 2013, 11:35:35 PM »
Correct. That is the purpose of the rtcActiveX unit. It adds a new handler to RTC Thread creation and destruction code, which makes sure that CoInitialize is called automatically for each RTC Thread after it is created and CoUninitialize before it is destroyed. This way, you don't need to call it every time before you need to use ActiveX controls from RTC events executed in background threads. And because the call is made only once for every thread, it will also cost less CPU time than it would if you are calling it manually.
Best Regards,
Danijel Tkalcec
Logged
zsleo
RTC Expired
Posts: 80
Re: RTC (win) Service auto-shutdown
«
Reply #5 on:
February 20, 2013, 11:55:29 PM »
Thanks.
The change will be made today.
Regards
Zane
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Dashboard
-----------------------------
=> General
=> 3rd-Party
=> Quick Start
-----------------------------
Subscription
-----------------------------
=> Support
Loading...