Change error to warning when OpenWindow() in thread

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
infratec
Always Here
Always Here
Posts: 7576
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Change error to warning when OpenWindow() in thread

Post by infratec »

Hi,

yes, I use OpenWindow() in a thread.

Why?
I only use it to show a message (like 'Wait a moment'), do some stuff and close it.
This is not possible with the standard MessageRequester() and I don't want API, since this program is
used in Windows and Linux.

Since PB 5.0 it is a bit tricky, since I always have to press 'play' to go on.
A 'warning' would be enough in my opinion, so that the program is still running with debugger on.
(Like for deprecated functions 'CreateGadgetList()' for example)

Bernd
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Re: Change error to warning when OpenWindow() in thread

Post by eesau »

Why don't you open your window in main and do the other stuff in a thread?
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Change error to warning when OpenWindow() in thread

Post by Fred »

The problem is it won't work on other OS. For your specific case, you should be able to use a timer, or put DisableDebugger/EnableDebugger around this call (not recommended).
infratec
Always Here
Always Here
Posts: 7576
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Change error to warning when OpenWindow() in thread

Post by infratec »

eesau wrote:Why don't you open your window in main and do the other stuff in a thread?
The overhead is to much.

I start a serial communication thread,
show 'Please do something' and wait with a timeout on the first received bytes.
If I receive them I go on in the thread else I close it.

And I have several different thread procedures which depends on a selectable modul.
Not every modul has the same requierements.
So I put the 'start stuff' inside the thread procedures.

Trust me, the overhead to implement this complete stuff additional in the main program is enormous.

Bernd
infratec
Always Here
Always Here
Posts: 7576
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Change error to warning when OpenWindow() in thread

Post by infratec »

Maybe an other trick is to open the window in the main task and hide it.

Than I show it and hide it inside the thread.
I have to test this.

Bernd
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Change error to warning when OpenWindow() in thread

Post by Fred »

With 5.10, you will have a PostEvent() command (which can be called from any thread, with a custom event code), so you will be able to ask for the window opening easily.
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: Change error to warning when OpenWindow() in thread

Post by jassing »

Fred wrote:With 5.10, you will have a PostEvent() command (which can be called from any thread, with a custom event code), so you will be able to ask for the window opening easily.
NICE! (the PostEvent())

I second the 'warning' on openwindow vs. error.
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Re: Change error to warning when OpenWindow() in thread

Post by sec »

5.0 will go to 5.10? Or 5.1, 5.2 ....?
Thanks
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Change error to warning when OpenWindow() in thread

Post by ts-soft »

sec wrote:5.0 will go to 5.10? Or 5.1, 5.2 ....?
Thanks
It is 5.00, after 5.00 comes next major 5.10, but often comes some bugfix Releases
as 5.01, 5.02 or 5.11 without new Features.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Change error to warning when OpenWindow() in thread

Post by Mistrel »

This change broke some of my code. I actually used this feature where I require windows to have independent message queues.

Add a note in the documentation but don't remove features that have been around forever!
Post Reply