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

Вниз

Использование SetTimer и KillTimer   Найти похожие ветки 

 
-=IGA=-   (2003-06-03 08:29) [0]

Может у когонибудь есть пример, напишите плиз.


 
Digitman   (2003-06-03 09:50) [1]

вот, разбирайся :


function TTransportThread.Send(const Data: IDataBlock; WaitResultTimeout: Integer): IDataBlock;
var
Context: DWord;
Msg: TMsg;
hWaitEvent: THandle;
hTimer: THandle;

procedure TimerProc(hWnd: Thandle; uMsg: DWord; idTimer: THandle; dwTime: DWord); stdcall;
begin
KillTimer(0, hTimer);
hTimer := 0;
CloseHandle(hWaitEvent);
hWaitEvent := 0;
end;

begin
Result := nil;
hWaitEvent := 0;
hTimer := 0;
if Assigned(Data) then
begin

if Data.Context = 0 then
Data.Context := GetCurrentThreadId;

if WaitResultTimeout <> 0 then
begin
hWaitEvent := CreateEvent(nil, False, False, nil);
Win32Check(hWaitEvent <> 0);
end;
try
Context := SendMessage(FhWnd, TM_SEND_DATABLOCK, wParam(Data), hWaitEvent);
if Context = 0 then
raise EACSConnectionError.CreateRes(@sACSConnectionError);
if WaitResultTimeout <> INFINITE then
begin
hTimer := SetTimer(0, 0, WaitResultTimeout, @TimerProc);
Win32Check(hTimer <> 0);
end;
try
while True do
case MsgWaitForMultipleObjects(1, hWaitEvent, False, INFINITE, QS_ALLINPUT) of
WAIT_OBJECT_0:
begin
Result := IDataBlock(SendMessage(FhWnd, TM_RECV_DATABLOCK, hWaitEvent, Context));
if not Assigned(Result) then
raise EACSConnectionError.CreateRes(@sACSConnectionError);
end;
WAIT_OBJECT_0 + 1:
while PeekMessage(Msg, 0, 0, 0, PM_REMOVE) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
WAIT_ABANDONED_0:
raise EACSConnectionError.CreateRes(@sACSConnectionError);
WAIT_FAILED:
raise EACSConnectionError.CreateRes(@sACSTimeoutError);
end;
finally
if hTimer <> 0 then
KillTimer(0, hTimer);
end;
finally
if hWaitEvent <> 0 then
CloseHandle(hWaitEvent);
end;
end;
end;


 
Polevi   (2003-06-03 13:20) [2]

LOL



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

Форум: "WinAPI";
Текущий архив: 2003.08.04;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 0.007 c
1-10254
Still Swamp
2003-07-21 10:09
2003.08.04
Как преобразовать адрес процедуры


1-10217
Kair
2003-07-19 09:45
2003.08.04
Кнопка на панели задач


14-10390
bobo
2003-07-17 09:48
2003.08.04
Посоветуйте компонент для работы с Excel 2000


1-10208
Prov
2003-07-22 09:21
2003.08.04
Фон едита и цвет текста


3-10122
Slv
2003-07-11 12:08
2003.08.04
Синхронное падение 2-х IB серверов





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский