🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1131

Re: Open a Form in a TServiceApplication during ServiceStart

#1131
From: Remy Lebeau (TeamB)
Date: Thu, 25 Oct 2007 16:57
29 lines
2172 bytes
"Marc" <info@mawnet.com> wrote in message 
news:4720c4bf@newsgroups.borland.com...

> Now I create a blank form and display [MyForm->Show()]
> it in the ServiceStart event.

DO NOT EVER display a UI from a service!!!  Services are background 
processes.  They are not supposed to interact with the user directly, with 
the exception of simply MessageBox() dialogs when notifications are needed. 
In fact, UIs in services are strictly not allowed anymore starting with 
Vista.  For a service to display a UI, the proper way to handle that (in any 
OS version) is to create a separate non-service application that runs after 
the user has logged in, and then have that application communicate with the 
service as needed using any of a number of IPC (inter-process communication) 
technologies that are available, such as sockets or named pipes.

> If I check with the debugger, it crashes when it tries to release my form 
> at the end of the application.

Another reason not to use UIs in services - TService is multi-threaded, and 
the VCL's UI components are not thread-safe.

> I have written services before that open Forms in the OnExecute loop.

You should never have been doing that in the first place.


Gambit 
Technical Details
Message-ID: <4720cb19$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4720c4bf@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8191050f071867e7
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4720c4bf@newsgroups.borland.com>
Subject: Re: Open a Form in a TServiceApplication during ServiceStart 
Date: Thu, 25 Oct 2007 09:57:04 -0700
Lines: 31
Organization: Lebeau Software
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 207.178.157.90
Message-ID: <4720cb19$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1193331481 207.178.157.90 (25 Oct 2007 09:58:01 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail