I am writing a dll library in Delphi with several threads she created. Let me describe the problem step by step. I apologize for the detailed description in advance: - (.
Forget the library for a while. I created a Windows application that will present views from multiple cameras. I created a window that is designed to display a view from a single camera and contains a TImage control. There is a thread (a descendant of the TThread descendants) that downloads the current camera image every couple of milliseconds and assigns it to the TImage control of this window (using the Synchronize () method). The application launches several instances of this window at startup (with a separate thread for each of them), so you can immediately view the live view from multiple cameras. What's more, all viewports are parents of the main application window, so they appear inside it.
Everything worked fine until I decided to put these two windows in the dll library. I just found it necessary for some reason, but now they are not important. Therefore, I created a new dll library, added an existing main window and a camera viewing window to the project, and exported a function that creates and returns an instance of the main window. When the main window is created, it creates several windows with a camera viewing window, which makes them parents.
Then, for testing purposes, I created an application that imports the above dll function from the library and calls it at startup to get an instance of the main window; then just shows it on the screen (in a non-modal state).
When I launched the application, it turned out that I could not get a single image from any camera. When I debugged it, I noticed that when a thread calls the Synchronize () method, it hangs forever. This did not happen before setting both of these windows in the dll.
And that is my problem. Honestly, this is my first approach to libraries with which I had to overcome many other problems. You may wonder why I use windows instead of frames ... Therefore, whenever I created an instance of TFrame in the dll, I would get an exception saying: "The xxx control does not have a parent window." I did not know what to do with this, so instead I used windows: - (.
Could you tell me what to do with the synchronization problem? The main thread does not seem to be blocked when the application is running, it accepts push buttons, etc. What is the problem?
Please, help!
Thanks in advance!
multithreading dll delphi
Mariusz schimke
source share