Please allow OpenWindow inside threads
Please allow OpenWindow inside threads
HI
I have multiple projects that uses OpenWindow inside a thread. They function as background processes and have their independent message processing loop. One example is an OpenGL application that spawns a drawing thread separate from the main window, it opens another window in its own thread to probe the extension list. I also have property windows that are non-modal and they require separate event processing as well. All of this functions perfectly in 4.50. I suggest that purebasic change the ERROR to a WARNING because it severely limits the way applications are developed.
Thanks!
I have multiple projects that uses OpenWindow inside a thread. They function as background processes and have their independent message processing loop. One example is an OpenGL application that spawns a drawing thread separate from the main window, it opens another window in its own thread to probe the extension list. I also have property windows that are non-modal and they require separate event processing as well. All of this functions perfectly in 4.50. I suggest that purebasic change the ERROR to a WARNING because it severely limits the way applications are developed.
Thanks!
Re: Please allow OpenWindow inside threads
"Have you tried turning it off and on again ?"
A little PureBasic review
A little PureBasic review
Re: Please allow OpenWindow inside threads
+1
Who's going to rewrite all the useful code snippets that use openWindow in a thread?

Who's going to rewrite all the useful code snippets that use openWindow in a thread?

Re: Please allow OpenWindow inside threads
At least there should be a 'MessageRequester()' which is not modal
and can be closed by second call or a 'CloseMessageRequester()'.
Like this:
If I have to do such a thing via PostEvent() and ...
it is a lot of overhead and a lot of work
Or I have to use always
Bernd
and can be closed by second call or a 'CloseMessageRequester()'.
Like this:
Code: Select all
MessageRequester("Info", "Please wait ...", #PB_Window_NotModal)
DoSomething()
CloseMessageRequester()
it is a lot of overhead and a lot of work

Or I have to use always
Code: Select all
DisableDebugger
Win = OpenWindow()
EnableDebugger
TextGadget()
DoSomething()
CloseWindow(Win)

Bernd
Re: Please allow OpenWindow inside threads
Not necessarily just messageRequester. Several "requester type" snippets rely on threaded behavior to accommodate input.
Re: Please allow OpenWindow inside threads
+1 -- it should be a warning..
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Please allow OpenWindow inside threads
If it works without problems on Windows but causes issues on the other platforms, I think PureBasic for Windows should allow it without any warnings at all and do something different for the other OS's. It's all well and good to be crossplatform but if targeting multiple platforms means crippling the Windows version to accommodate the other operating systems then we're not doing it right. Just my opinion, worth the standard two cents.Fred wrote:The problem is it won't work on other OS.
BERESHEIT
Re: Please allow OpenWindow inside threads
I agree. Better approach is to maximize OS support and let documentation do the rest. 
Elements of this are already in play with Callbacks, OnError Lines, etc.
http://www.purebasic.com/documentation/ ... cific.html

Elements of this are already in play with Callbacks, OnError Lines, etc.
http://www.purebasic.com/documentation/ ... cific.html
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: Please allow OpenWindow inside threads
Then you will get some angry comments when someone have a 100% working PB program on Windows and want to do a Linux or OS X version as it won't work at all. We enforce it, but if you really want, you can put some disabledebugger around the calls.
Re: Please allow OpenWindow inside threads
Do you remember any commend about that?Fred wrote:Then you will get some angry comments when someone have a 100% working PB program on Windows and want to do a Linux or OS X version as it won't work at all. We enforce it, but if you really want, you can put some disabledebugger around the calls.
I just remember threads where people are confused, why it is not working ...
and they just want to know what they have done wrong ... after you
have explained it, it was ok again, just angry about that they have
used time for programing something wrong ... so it could
be improved in that way to tell them that it will not work on linux/ mac.
A warning on windows instead of an error is the better choice.
On linux and mac it should be still an error.
There are always people who complain about something, if you can
stand this every-month-topic, still your choice

But for me, there is no reason behind this "error".
MFG PMV
Re: Please allow OpenWindow inside threads
I admit didn't even try it, but if the problem is only reported by the debugger, and if you can use the enable/disable debugger as Fred explained to suppress the error on Windows I don't think this is a problem at all.
It's a remainder that on another os could not work at all and you should find another way if you want port your program on another os.
It's a remainder that on another os could not work at all and you should find another way if you want port your program on another os.
"Have you tried turning it off and on again ?"
A little PureBasic review
A little PureBasic review
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Please allow OpenWindow inside threads
Sure, fair enough. I like to send messages to the main thread myself and the new PostEvent() will suit me fine.if you can use the enable/disable debugger as Fred explained to suppress the error on Windows I don't think this is a problem at all.
BERESHEIT
Re: Please allow OpenWindow inside threads
Thanks Bernd!
The debugger also disallows WaitWindowEvent() and WindowEvent() from executing from inside a thread.
The debugger also disallows WaitWindowEvent() and WindowEvent() from executing from inside a thread.
Re: Please allow OpenWindow inside threads
Yes. Because of that I'm using something like:kandl wrote:The debugger also disallows WaitWindowEvent() and WindowEvent() from executing from inside a thread.
Code: Select all
Procedure _OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$, Flags=0, ParentID=0)
Protected Result = 0
DisableDebugger
Result = OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$, Flags, ParentID)
EnableDebugger
ProcedureReturn Result
EndProcedure
Procedure _WaitWindowEvent(Timeout=#PB_Default)
Protected Result = 0
DisableDebugger
Result = WaitWindowEvent(Timeout)
EnableDebugger
ProcedureReturn Result
EndProcedure
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
-
- User
- Posts: 81
- Joined: Sat Mar 13, 2010 4:50 pm
Re: Please allow OpenWindow inside threads
I would like to add my voice to those calling for a less heavy-handed approach to opening a window in its own thread. Clearly, not being able to do it in Linux or the Mac OS is an important limitation which those writing cross-platform programs need to be aware of. However there are other important limitations in some PureBasic commands. They are dealt with in the documentation and that is the proper place.
My own PureBasic is set up with only the compiler for Windows active. I frequently use direct calls to the Windows API which obviously means my programs can run only in Windows. Despite this, I am instructed that I cannot open a window in its own thread! I can turn off the compiler as mentioned, but I am not fond of this inelegant solution. I don’t think it should be necessary.
My own PureBasic is set up with only the compiler for Windows active. I frequently use direct calls to the Windows API which obviously means my programs can run only in Windows. Despite this, I am instructed that I cannot open a window in its own thread! I can turn off the compiler as mentioned, but I am not fond of this inelegant solution. I don’t think it should be necessary.