Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.025 c
1-1100000133
xkiller
2004-11-09 14:35
2004.11.28
Как отловить событи, когда курсор вышел за пределы фотографии?


14-1100076018
Григорьев Антон
2004-11-10 11:40
2004.11.28
Так вычисляются роботы :))


11-1083348519
4kusNick
2004-04-30 22:08
2004.11.28
Помогите с Undo в RichEdit


3-1099118308
GURU-RU@bk.ru
2004-10-30 10:38
2004.11.28
Автосохранение БД


3-1099312758
sql
2004-11-01 15:39
2004.11.28
Как убрать концевые пробелы в TDBEdit?




   Наверх