<< Click to display table of contents >>

It is not recommended to display a modal form from inside this event: while showing this form, functioning of TRVCamReceiver and TRVCamSender components will be paused.

It happens because this event is called from Synchronize method of a background thread (Synchronize allows calling a thread method in the context of the main process). Because of this, all other threads cannot call Synchronize until you finish processing this event. If you display a modal form, it may take a lot of time.

Workarounds:

1.(for VCL and LCL, Windows) Use PostMessage to post message to a form, and display a form in the message handler.

2.(for all frameworks) Use TTimer. Make it disabled by default. In this event, enable it, and in the first execution of OnTimer, disable it and show a form.

 

Example

This example explains how to use a timer.

The demo ClientServer\VideoChats\ChatRooms\ needs to display a chat form from RVCamReceiver1.OnRequestJoinGroup event. The demo displays it as a non-modal form. If we want to display a modal form, we can do the following steps:

1.Placing Timer2: TTimer on a form. Assigning a small value to Interval, assigning Enabled = False

2.Instead of calling frmRoom.ShowModal, calling Timer2.Enabled := True. Do not hiding the main form.

3.Processing the timer procedure:

procedure TfrmMain.Timer2Timer(Sender: TObject);
begin
  Timer2.Enabled := False;
  frmRoom.ShowModal;
end;