Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.11.28;
Скачать: CL | DM;

Вниз

TServiceApplication - Pause, Continue, Stop   Найти похожие ветки 

 
andrey__   (2004-11-11 15:52) [0]

Как програмно усуществить "паузу", "продолжение" и "стоп" сервисного приложения. Я смотрел методы TService но ночего подобного не нашёл. Х


 
Семен Сорокин ©   (2004-11-11 16:28) [1]

Service threads + F1

Example

This service beeps every 500 milliseconds from within the standard thread. It handles pausing, continuing, and stopping of the thread when the service is told to pause, continue, or stop.

1 Choose File|New|Other and double-click Service Application in the New Items dialog. The Service1 window appears.
2 In the interface section of your unit, declare a new descendant of TThread named TSparkyThread. This is the thread that does the work for your service. The declaration should appear as follows:

TSparkyThread = class(TThread)
   public
     procedure Execute; override;
 end;

3 In the implementation section of your unit, create a global variable for a TSparkyThread instance:

var
 SparkyThread: TSparkyThread;

4 In the implementation section for the TSparkyThread Execute method (the thread function), add the following code:

procedure TSparkyThread.Execute;
begin
 while not Terminated do
 begin
   Beep;
   Sleep(500);
 end;
end;

5 Select the Service window (Service1), and double-click the OnStart event in the Object Inspector. Add the following OnStart event handler:

procedure TService1.Service1Start(Sender: TService; var Started: Boolean);
begin
 SparkyThread := TSparkyThread.Create(False);
 Started := True;
end;

6 Double-click the OnContinue event in the Object Inspector. Add the following OnContinue event handler:

procedure TService1.Service1Continue(Sender: TService; var Continued: Boolean);
begin
 SparkyThread.Resume;
 Continued := True;
end;

7 Double-click the OnPause event in the Object Inspector. Add the following OnPause event handler:

procedure TService1.Service1Pause(Sender: TService; var Paused: Boolean);
begin
 SparkyThread.Suspend;
 Paused := True;
end;

8 Finally, double-click the OnStop event in the Object Inspector and add the following OnStop event handler:

procedure TService1.Service1Stop(Sender: TService; var Stopped: Boolean);
begin
 SparkyThread.Terminate;
 Stopped := True;
end;


 
andrey__   (2004-11-11 17:18) [2]

>Семен Сорокин ©   (11.11.04 16:28) [1]

Этот вариант подходит для служб основонй цыкл работы которых организован в доп.потоке

TSparkyThread = class(TThread)
  public
    procedure Execute; override;
end;

var
SparkyThread: TSparkyThread;

А у меня его нет.

Мне нужен авриант напоминающий работу SQLServera там есть маленькая форма содержащая все кнопки управления службой из оснастки «Службы». Все действия на этой форме отображаются в оснастке «Службы». Т.е. если ты на форме нажал кн. "Pause"
то состояние приостановлено появляется и в оснастке «Службы» для данного сервиса.


 
andrey__   (2004-11-12 09:49) [3]

ало


 
Erik1 ©   (2004-11-12 10:02) [4]

Тогда делай сам флажками, у тебя же есть основной цикл, там и обрабатывай свои флажки.


 
VMcL ©   (2004-11-12 10:03) [5]

ControlService, StartService, QueryServiceStatus, QueryServiceStatusEx



Страницы: 1 вся ветка

Текущий архив: 2004.11.28;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.04 c
1-1100384466
Лев Ландау
2004-11-14 01:21
2004.11.28
Тонкости WebBrowser ...


14-1100206583
ArMellon
2004-11-11 23:56
2004.11.28
Народ вот делаю чат


6-1095347411
serg128
2004-09-16 19:10
2004.11.28
Как програмно расшарить(дать полный доступ) папку на компе?


14-1100107401
lipskiy
2004-11-10 20:23
2004.11.28
Посоветуйте формат хранения данных


1-1100436459
Polycom
2004-11-14 15:47
2004.11.28
Код ASCII