Dreaded not Responding message (even when ok)

Community Forums/General Help/Dreaded not Responding message (even when ok)

Matty(Posted 2015) [#1]
In blitzplus and blitz it is possible to add things like waitevent 0 during long running loops in windowed mode to ensure that the dreaded 'not responding' message doesn't appear on screen with batch processes even though the application certainly is doing something.

However - sometimes - such as when you are saving out an image that is huge (4000x5000 pixels) the actual save operation takes considerable time (about 5 or more seconds) which you can't do anything to stop the 'not responding' message appearing in the title bar.....or is there?

It doesn't bother me too much for my own personal stuff since I know it is still running in the background (doing the write to disk operation) but is there a way to prevent this message from coming up when running in windowed mode and performing a long hard disk write with the saveimage command?

from Matt


xlsior(Posted 2015) [#2]
The "app not responding" is a windows 'feature' that happens when the program hasn't checked the eventqueue for five seconds.

Unless you can throw the save routines into a separate thread and have the main program continue to communicate with the OS, there probably isn't much you can do to prevent it.


Henri(Posted 2015) [#3]
Hi,

it certainly is possible simply by sending a message to OS (Windows I presume ?) that the application is still alive.


In BlitzMax it could be done like so:
Local msg:TMSG = New TMSG, bool:Int

Repeat
	bool = GetMessage(msg, Null, 0, 0)
	
	Select bool
	
		Case - 1	' Error
			Exit
		Case 0		' Quit
			DebugLog "Quitting..."
			Exit
		Default
			
	End Select
	
	TranslateMessage(msg)
	DispatchMessage(msg)
Forever



Now, how can we send a message when our program doesn't have control ?
There are two options: Either start the operation in a new process or in a new thread which enables the application have control during the save operation.

In BlitzMax these are builtin, not sure how this would be done in Blitz+ , but I assume it has means to access WinAPI.

-Henri


Matty(Posted 2015) [#4]
Thanks henri....create process is a good idea however i usually run my progs straight from the ide (since it is only me who uses these utilities) but its good to know. However i thought blitz runs process within its own environment and waits for the process to return. Ill check later.


Yasha(Posted 2015) [#5]
If you can afford to use your own save function instead of the built-in one, design it to be asynchronous and perform the save operation in steps, with a return to the main event loop in between. If using BlitzMax, something like coroutines might help.


Matty(Posted 2015) [#6]
Thanks yasha. Its more a mild annoyance than anything else as im the only one who uses it so it doesnt need to be ultra user friendly or a good ux. Thats a good point though. The reason i use blitz for this over a threaded language is simply that it is so quick to put a little image editor together that does a bunch of ops in a batch.


grable(Posted 2015) [#7]
PollSystem does some of this, though you need to use hooks for it to work with things other than os events.


Blitzplotter(Posted 2015) [#8]
it certainly is possible simply by sending a message to OS (Windows I presume ?) that the application is still alive.


I got around this issue within B3D when loading large files by the insertion of debug and associated vwait statements.