PDA

View Full Version : onexecute و onstart در سرویسها



lord_viper
پنج شنبه 15 شهریور 1386, 00:17 صبح
با سلام
در سرویسها چه موقعی از onexcuteو چه موقعی از onstart استفاده میشه ؟(لطفا با مثال توضیح بدین)
با تشکر

vcldeveloper
پنج شنبه 15 شهریور 1386, 03:26 صبح
راهنمای دلفی بطور واضح این تفاوت را توضیح داده:


OnExecute:
Occurs when the thread associated with the service starts up.

Description
If you are not spawning a new thread to handle individual service requests in an
OnStart event handler, this is where you implement the service.
When the OnExecute event handler finishes, the service thread terminates.
Most OnExecute event handlers contain a loop that calls the service thread’s
ProcessRequests method so that other service requests are not locked out.


OnStart:
OnStartup occurs when the service first starts up, before the OnExecute event.

Description
This event should be used to initialize the service. For example,
if each service request is handled in a separate thread
(a good idea if handling the request takes much time) the thread for a request is
spawned in an OnStart event handler.