I am reflecting on some ideas for creating a DLL for some of the common things that I do. One thing I would like to check if possible is to start the thread inside the DLL. I am sure that I can at least start it, and automatically release it at the end (and force it to decisively cease its “I”), which I see will not be a problem. But as soon as I start, I don’t see how I can continue to communicate with him (especially to stop him), mainly because every DLL call is unique (as far as I know), but I also know very little about the subject.
I saw how in some cases DLLs can be loaded at the beginning and released at the end when it is no longer needed. I have 0 knowledge or experience with this method, except as soon as I see something related to it, I can’t even tell you what and how, I don’t remember. But is it possible?
I know about ActiveX / COM, but this is not what I want - I would like only a basic DLL that can be used in different languages (in particular, in C #).
Also, if possible, how will I make callbacks from the DLL to the application? For example, when I start a thread, I will most likely assign a function (which is located inside the EXE) as an event handler (which are launched from the DLL).
So, I guess I am asking: how to load the DLL for continuous operation and release it when I have finished - as opposed to the simple method of calling individual functions in the DLL as needed. In the same case - I could assign variables or create objects inside a DLL. How can I assure that as soon as I assign this variable (or create an object), how can I make sure that the variable or object will still be available the next time the DLL is called? Obviously, this will require a DLL initialization / termination mechanism (IE create objects inside a DLL when loading a DLL and free objects when unloading a DLL).
EDIT: In the end, I will wrap the DLL inside the component, so when the component is instantiated, the DLL is loaded and the corresponding stream inside the DLL is created, when the component is free, the DLL is unloaded. You also need to make sure that if there are, for example, 2 of these components, then there will be two instances of the DLL loaded for each component.
Does this have anything to do with using IInterface? Because I also have 0 experience with this.
No need to answer it directly using the sample source code - a link to a good tutorial will be great.