BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with Callbacks

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier)
View previous topic :: View next topic  
Author Message
Don Gilbert
Guest





PostPosted: Wed Dec 13, 2006 3:43 am    Post subject: Help with Callbacks Reply with quote



Hello Friends,

After some searching and much trial and error, I finally got callbacks from
the AppServer working.
Each client registers the callback with the remote data module, and a list
of remote data module instances is kept the the AppServer main form (added
in RDM OnCreate and removed in RDM OnDestroy). The callback is invoked by a
timer on each RDM, and the timers are enabled from the main form when the
callback to each client is required. I am using MultipleInstance, Single
Thread for the RDM's

I am using this to callback to notify each client of changed data (available
from the AfterUpdateRecord event). However, first I have to save this data
(I use an olevariant) and I currently use a variable in the main form.

My problem - another AfterUpdateRecordEvent can occur while the first
callback sequence is running, changing the data in the main form variable.
Can anyone give me some pointers as how to approach and deal with this
situation?

I clearly don't understand this stuff enough yet - I'm one of CodeGearr's
target 'occupational developers' !
Back to top
Hamed Fallahnia
Guest





PostPosted: Wed Jan 03, 2007 9:38 pm    Post subject: Re: Help with Callbacks Reply with quote



Hi,
Something that just came to my mind is using Semaphores or Mutexes, or Even
Critical Sections. Because you are using Single Thread, I think Critical
Sections would work for you.
In your server application's main form, define a private variable like this:
CS: TRTLCriticalSection.
Then use InitializeCriticalSection(CS) in your OnCreate event of the form
and use DeleteCriticalSection(CS) in OnDestroy event. Then from each
procedure that you want to make a chane to your variable, use this block:

EnterCriticalSection(CS);
//modify your variables
//When the variable is ready and there is no more change needed, send it
back to clients
//at last call:
LeaveCriticalSection(CS);

This way if another AfterUpdate event comes to this procedure at the time if
the first event is at the middle of it's job, the second one would be held
in first line until the first one is finished and released the critical
section.

Cheers,

Hamed

"Don Gilbert" <drdongilbert (AT) ntlworld (DOT) com> wrote in message
news:457f2257 (AT) newsgroups (DOT) borland.com...
Quote:
Hello Friends,

After some searching and much trial and error, I finally got callbacks
from the AppServer working.
Each client registers the callback with the remote data module, and a list
of remote data module instances is kept the the AppServer main form (added
in RDM OnCreate and removed in RDM OnDestroy). The callback is invoked by
a timer on each RDM, and the timers are enabled from the main form when
the callback to each client is required. I am using MultipleInstance,
Single Thread for the RDM's

I am using this to callback to notify each client of changed data
(available from the AfterUpdateRecord event). However, first I have to
save this data (I use an olevariant) and I currently use a variable in the
main form.

My problem - another AfterUpdateRecordEvent can occur while the first
callback sequence is running, changing the data in the main form variable.
Can anyone give me some pointers as how to approach and deal with this
situation?

I clearly don't understand this stuff enough yet - I'm one of CodeGearr's
target 'occupational developers' !
Back to top
Don Gilbert
Guest





PostPosted: Thu Jan 04, 2007 3:45 am    Post subject: Re: Help with Callbacks Reply with quote



Quote:
Cheers,

Hamed

And again I thank you, my friend !

Regards and best wishes
Don
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.