I need to create a DLL which exports 2 functions:
a) the function to create a new thread with window
b) the function to terminate that thread (and we need to destroy it's window)
with using WINAPI (MS VC++ 6).
The reason of my issue that DLL should be attached to main application which can stay busy for a long time and this application are not responding to user's activity, but if there stays at least one active window, the user would not be confused.
I'm not C programer, so please be patient.
Here code that I wrote using google, msdn, etc. A problem that I can't create the window (the handle is NULL) so I need you mature advice. And 2nd question is what I need to terminate the child thread by calling function from the main thread (because of peeking windows messages I think I can't use semaphore... )?
It is a very bad idea to create a window in any secondary thread. Don't do it.
Instead you should move all the things making your App busy from the main thread to a one or more worker threads.
It is a very bad idea to create a window in any secondary thread. Don't do it.
Instead you should move all the things making your App busy from the main thread to a one or more worker threads.
Yes, I think so, but that application is Oracle Forms runtime, I can't modify it. Only available to change is my module which executes by this application :'(
Oh, I remember, there are exists some way to interact few applications between each others... it's pipes? so I can create independent application to read a pipe from main app. I think right?
Oh, I remember, there are exists some way to interact few applications between each others... it's pipes? so I can create independent application to read a pipe from main app. I think right?
Yes, but you will have to modify this "application is Oracle Forms runtime" too.
And there are many types of IPC: pipes, mailslots, sockets, clipboard, file mapping and so on...
Well, as for me, there's nothing wrong in creating window in a secondary thread. Of course if you know what you do. And the problem with non-created window has nothing to do with the thread.
russian desc:
Внешнее приложение запускает мой модуль (форма, написанная на специальном языке) и выполняет его. В моём модуле нет возможности влиять на обработку сообщений ОС, потому я не могу сделать так, чтобы окно приложения не зависало при длительных операциях, но я могу подключить к модулю любую динамическую библиотеку и вызвать функции из этой библиотеки.
Если я сделаю принудительную отрисовку основного приложения из DLL, то всё равно сообщения WM_* ставятся в очередь и не будут обработаны пока программа выполняет вычисления.
Хотелось бы, чтобы в DLL было две функции - создать окно в новом потоке, уничтожить поток (в теории, еще третья функция нужна для отображения в этом окошке статуса основного приложения).
Проблема в том, что в моём коде где-то ошибки, т.к. окно не создаётся, то есть, в функции doSomething локальная переменная hWnd == NULL. В чём проблема? И ещё вопрос - как уничтожить потом второй поток из основного потока, ведь если поток будет зациклен на чтении оконных сообщений, то пока не придёт какое-нибудь сообщение в окно, поток не обновит информацию о семафоре или о другом событии.
When you pass a pointer of a stack variable to another thread, the stack can be already destroyed to the moment when the thread tries to dereference the pointer. And garbage comes as the result.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.