• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 
November 21, 2024, 11:19:33 am

News:

SMF - Just Installed!


nrDataProcessor and TEvent

Started by Arne, January 26, 2011, 10:47:54 am

Previous topic - Next topic

Arne

I got a problem regarding nrDataProcessor.OnDataPacket in conjunction with TEvent objects (Delphi 2007 (nrCommLib 9.12).
Right now I have a nrDataProcessor.OnDataPacket running and when it parsed a datagram it sets a flag to true. In my main application I poll that flag for true to continue in my code.
It's working, but not a good idea. Now I want to use a TEvent object as they seem to be made for that purpose.
I create an instance of TEvent in FormCreate.

myEvent := TEvent.Create(nil, True, False, '');


Now my nrDataProcessor.OnDataPacket doesn't set the flag anymore, but does a

myEvent.SetEvent;

at the end.

My main application is waiting with

  case mDataPacketCompleteEvent.WaitFor(500) of
    wrSignaled: begin
    (...)
    end;
    wrTimeout: begin
    (...)
    end
    else begin
    (...)
    end;
  end;
  myEvent.ResetEvent;


Now it always runs into the 'wrTimeout' branch.
I tried to set "UseMainThread" to True/False: no change.
Any chance to use TEvents correctly here?