Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2004.11.28;
Скачать: [xml.tar.bz2];

Вниз

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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.044 c
3-1099309338
RusLAN_
2004-11-01 14:42
2004.11.28
Firebird. Копия БД (Тень)


14-1099924400
Piter
2004-11-08 17:33
2004.11.28
А может ли библиотека сама выгрузится?


3-1099402889
denis24
2004-11-02 16:41
2004.11.28
dbmemo и поле MEMO


8-1093699861
Кирилл
2004-08-28 17:31
2004.11.28
Ошибка командной строки


14-1100332550
Vaitek
2004-11-13 10:55
2004.11.28
SPAM BLIN DOSTAL





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский