Delphi and prevent event handling
Posted
by pKarelian
on Stack Overflow
See other posts from Stack Overflow
or by pKarelian
Published on 2010-03-07T09:57:16Z
Indexed on
2010/03/08
9:36 UTC
Read the original article
Hit count: 607
How do you prevent a new event handling to start when an event handling is already running?
I press a button1 and event handler start e.g. slow printing job. There are several controls in form buttons, edits, combos and I want that a new event allowed only after running handler is finnished.
I have used fRunning variable to lock handler in shared event handler. Is there more clever way to handle this?
procedure TFormFoo.Button_Click(Sender: TObject);
begin
if not fRunning then
try
fRunning := true;
if (Sender = Button1) then // Call something slow ...
if (Sender = Button2) then // Call something ...
if (Sender = Button3) then // Call something ...
finally
fRunning := false;
end;
end;
© Stack Overflow or respective owner