Jump to content
Sonjli

Tasks communication

Recommended Posts

Hi,

I hardly use tasks comm.

A very simple question: is this code right?

if lTask.Comm.Writer.IsFull then
begin
	lLocalLogger.Debug(Format('Task Queue is FULL %s...', [lTask.Name]), lSenderLogTagMain);
	Sleep(1000);
	...
end
else
	lTask.Comm.Send(WM_RECEIVE_DO, TOmniValue.CastFrom < IBroadcastMessage < TDataPacketBody >>(ABroadcastMessage));
...

 

Share this post


Link to post

I try to better explain my problem. I understand the last question was a bit (lot...) stupid 😉

I need to know if the receiver task is alive.

In some cases the receiver task has gone so I continue to send messages to it and I receive this error: "TOmniCommunicationEndpoint.Send: Queue is full"

How can I avoid this problem? I would like to do something like this:

if not MyTask.IsDead then
	MyTask.Comm.Send(...)

// or

if WatchDog(MyTask) <> Dead then
	MyTask.Comm.Send(...)
    
// where WatchDog can check the healty of the Task and the MyTask.Comm.Writer.IsFull

Thanks in advance,

Eddy

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×