Access violation when using UniAlerter

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
plevrier
Posts: 4
Joined: Fri 16 Dec 2016 09:03

Access violation when using UniAlerter

Post by plevrier » Thu 23 Feb 2017 09:45

Hi,

I have a DataModule with a UniConnection and a UniQuery. This DataModule is created by several threads (6) for updating / inserting data into postgres and works like a charm. The Datamodules are created by the thread in the .execute method.

I decided to add an UniAlerter on the DataModule. I just put it without any code and then when I fire up the application, 1 out of 4 times I get an access violation. The debugger stops at System.Classes method Threadproc (try Thread.execute) during startup of the application.

The callstack is at TPgSQLnotificationsThread.execute

I noticed that I have the UniConnection connected at designtime.
When I set connected = false (designtime) the access violation does not occur.

Anybody else had this issue ? I think it is a thread management bug inside the UniAlerter component.

I am using version Unidac 6.4.16 in Delphi XE5 ; Postgres 9.5.5

regards,
Pascal

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Access violation when using UniAlerter

Post by azyk » Tue 28 Feb 2017 09:52

To use TUniAlerter in a multithreaded application the TUniAlerter.Start method should be executed in the main application thread, for example by using the Synchronize method:

Code: Select all

Synchronize(UniAlerter1.Start);

Yves
Posts: 19
Joined: Thu 10 Mar 2016 08:01

Re: Access violation when using UniAlerter

Post by Yves » Thu 31 Aug 2017 14:58

How can a UniAlerter be used in a seperate thread without Synchronize?
Especially for sending and receiving database events. In the receiving event an UniQuery using the same UniConnection as the UniAlerter is used. That means the UniAlerter.OnEvent have to run in the same thread and not in the main application thread. I noticed that UniAlerter.OnEvent is fired in the main application thread and not in the expected thread.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Access violation when using UniAlerter

Post by azyk » Wed 06 Sep 2017 12:49

The TUniAlerter.OnEvent call using the Synchronize method is implementation specificity in UniDAC.

However, you can leave your suggestion about implementing alert mechanism in UniDAC without using the Synchronize method at our UserVoice ( http://devart.uservoice.com/forums/1046 ... components ). If the suggestion gets enough votes, we will consider the possibility of its implementation.

Post Reply