Callback for TD7.1

Discussion forum about all things Team Developer 7.x
Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 1085
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Callback for TD7.1

Post by Dave Rabelink » 30 May 2018, 09:56

Ported Callback library to TD7.1.

(no x64 version yet)

http://samples.tdcommunity.net/index.ph ... rch_mode=f
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 1085
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Callback for TD7.1

Post by Dave Rabelink » 30 May 2018, 09:58

I found this when using callback library in TD7.1:

When TD7.1 is running without threads, callback is working ok.

But I wanted to see what happens when using callback within a thread. This because we would like to run some code which is executed as thread which uses callbacks.

An example is enumerating window handles on the system in the background and report any changes and redisplay data in the main application GUI.
This actually does not work. The callback is not fired and no results are processed OR TD actually hangs/crashes.

The reason is actually obvious when looking at the callback library implementation:

It performs the callback (SalCompileAndEvaluate) at the moment the WinApi callback (c++ function in the dll) is called by the main function which calls the callback internally.

And then it uses the current context !!

As callback is used in a thread and you are unsure what the context is. It could be anything and probably will not be the TD thread context.
This will result in no callbacks fired and could hang/crash TD.


I'm working on a new callback library version which will be more "thread-safe" for TD 7.1.

My first tests show that this change actually works OK in a TD thread, so that using callback in threads can be used.

But I need more time to test this and make it more robust. The callback library interface will change though, so this will be incompatible with the previous versions.

You can still use the dll provided there, as long you do not use it in a thread.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests