Вниз
Скачать: 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.024 c
14-1099924567
Piter
2004-11-08 17:36
2004.11.28
А где находятся функции типа KeSetTimer, KeWaitForSingleObject?


4-1097785196
BaG
2004-10-15 00:19
2004.11.28
События клавишиатуры в Windows


14-1099975942
YurikGL
2004-11-09 07:52
2004.11.28
Посмотреть!!!


1-1100547783
BiS
2004-11-15 22:43
2004.11.28
Модули


1-1100628629
rom
2004-11-16 21:10
2004.11.28
проблемы с перерисовкой надписи




   Наверх