Page 2 of 3

Posted: Fri Aug 25, 2006 8:08 am
by netmaestro
Hi PB - I'm pretty sure it was a (feeble? did I say that?) joke.

Posted: Fri Aug 25, 2006 9:00 am
by mskuma
Back home - so giving this a go..
netmaestro wrote:OK, one more test. Run this code, close the window and then immediately try to run it again.
I got the "Already Running!" box after re-running it. As I type this I see it is still in the Task Manager quite a while later (about a minute later ). I guess I've got some fundamental system problem here.. I'll investigate some more. Thanks netmaestro alot for your kind help.

Posted: Fri Aug 25, 2006 9:03 am
by netmaestro
Well - That's bad. It really is still running then. That's bad. Dunno if I mentioned this before but that's not good. It shouldn't be happening at all.

Posted: Fri Aug 25, 2006 9:05 am
by netmaestro
Anyway, it's not your code. Could be something strange in your system, like a virus, rootkit, adware, etc. or could even be a bug in PureBasic.

Posted: Fri Aug 25, 2006 9:20 am
by mskuma
Amazingly, the process still hasn't been killed after about 10 mins..

Posted: Fri Aug 25, 2006 1:59 pm
by Trond
netmaestro wrote:Hi PB - I'm pretty sure it was a joke.
You people don't have humour.
(feeble? did I say that?)
No, you didn't.


Test this:

Code: Select all

Procedure Init()
  InitSprite()
  OpenWindow(0, 0, 0, 800, 600, "test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
 
  OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0)
EndProcedure

Procedure MainLoop()

  quit.l = 0

  Repeat
    eventID = WaitWindowEvent()
  Until quit = 1 Or eventID = #PB_Event_CloseWindow
 
  CloseScreen()
  CloseWindow(0)
  
  MessageRequester("End", "Before end")
  End
  MessageRequester("End", "After end")
EndProcedure

Init()

MainLoop()

Posted: Fri Aug 25, 2006 9:53 pm
by mskuma
Well this is very interesting.. I don't have the process problem with Trond's code.. While watching the task manager, immediately after clearing the "before end" dialog, I see the task disappear along with the window. The dialog "after end" is not seen (as could be expected). Thanks very much Trond for this - now just have to figure out why it's ok.. obviously there's no keyboard stuff in this one. I'll tinker with this to see what I can find.

Posted: Fri Aug 25, 2006 10:08 pm
by mskuma
After an initial investigation, I think the issue is due to ExamineKeyboard(). The following code causes the problem, but if I comment out ExamineKeyboard() I don't have the problem.

Code: Select all

Procedure Init() 
  InitSprite() 
  InitKeyboard()
  
  OpenWindow(0, 0, 0, 800, 600, "test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) 
  
  OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0) 
EndProcedure 

Procedure MainLoop() 

  quit.l = 0 
  
  ExamineKeyboard() 

  Repeat 
    eventID = WaitWindowEvent() 
  Until quit = 1 Or eventID = #PB_Event_CloseWindow 
  
  CloseScreen() 
  CloseWindow(0) 
  
  End 

EndProcedure 

Init() 

MainLoop()

Posted: Fri Aug 25, 2006 10:16 pm
by netmaestro
Aha!! I see the problem now. You are using WaitWindowEvent() together with ExamineKeyboard()! OK - replace WaitWindowEvent() with WindowEvent() and make sure there's a delay(1) in the loop - that should remove the problem. Why didn't I see that before?

Posted: Fri Aug 25, 2006 10:27 pm
by mskuma
Thanks but I'm still getting the issue

Code: Select all

InitSprite() 
InitKeyboard()

OpenWindow(0, 0, 0, 800, 600, "test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) 

OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0) 

ExamineKeyboard() 

Repeat 
  Delay(1)
  eventID = WindowEvent() 
Until eventID = #PB_Event_CloseWindow 

CloseScreen() 
CloseWindow(0) 

End 
I thought maybe changing to

Code: Select all

eventID = WaitWindowEvent(1) 
might be worth it, but it not reliable either. I say reliable because after running so many test cases, there are rare times that it does work with WaitWindowEvent(1) but usually it locks up the process.

Posted: Fri Aug 25, 2006 10:34 pm
by netmaestro
I was so sure that would fix it. :cry: But it's beginning to look as if ExamineKeyboard() isn't working correctly on your machine. What are your specs on the machine with the problem?

As a temporary fix until you get it sorted out you could switch to GetAsyncKeyState_() instead of ExamineKeyboard. That should definitely fix it.

Posted: Fri Aug 25, 2006 10:45 pm
by mskuma
Thanks for that - well using the following gives no problem..

Code: Select all

InitSprite() 
InitKeyboard()

OpenWindow(0, 0, 0, 800, 600, "test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) 

OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0) 

;ExamineKeyboard() 
GetAsyncKeyState_(#PB_Key_Escape) 

Repeat 
  eventID = WaitWindowEvent() 
Until eventID = #PB_Event_CloseWindow 

CloseScreen() 
CloseWindow(0) 

End 
So you were right. Why would GetAsyncKeyState work and not ExamineKeyboard. What is also scary is why others don't see this problem.

My machine spec is a Toshiba Satellite P20 laptop running XP Pro SP2.

[edit: fortunately the keyboard is just a way to bail out - I get users to press an on-screen button, but this behaviour has got me wondering..]

Posted: Fri Aug 25, 2006 10:46 pm
by Xombie
Another thing to try on yours ... put ExamineKeyboard() before OpenWindowedScreen() and try it. Although I should probably read the history of this conversation before mentioning this...

..: Edit :.. And does this still stay in memory?

Code: Select all

InitSprite() 
InitKeyboard() 
;
If OpenWindow(0, 0, 0, 800, 600, "test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) 
   ;
   If OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0) 
      ;
      ExamineKeyboard() 
      ;
      quit.l = 0 
      ;
      Repeat 
         EventID = WaitWindowEvent() 
      Until quit = 1 Or EventID = #PB_Event_CloseWindow 
      ;
      CloseScreen() 
      ;
   EndIf
   ;
   CloseWindow(0) 
   ;
EndIf
;
End 
..: Edit 2 :.. And what happens if you add ...

Code: Select all

If KeyboardPushed(#PB_Key_Escape) : quit = 1 : EndIf
... that line somewhere in your loop? Just curious to see what happens, Mr. Guinea Pig :) Although, I suppose you'll need to put the ExamineKeyboard() call in your loop too.

..: Edit 3 :.. Did you check your directx drivers on that machine? What was that program called? dxdialog? Something like that?

Posted: Fri Aug 25, 2006 10:47 pm
by netmaestro
They're completely different technologies. ExamineKeyboard() uses DirectX whereas GetAsyncKeyState_() does not.

Posted: Fri Aug 25, 2006 10:58 pm
by mskuma
Thanks Xombie.
Xombie wrote:Another thing to try on yours ... put ExamineKeyboard() before OpenWindowedScreen() and try it.
I think it's not possible to do it (gets an error)
..: Edit :.. And does this still stay in memory?
Yes
..: Edit 2 :.. And what happens if you add ...

Code: Select all

If KeyboardPushed(#PB_Key_Escape) : quit = 1 : EndIf
... that line somewhere in your loop? Just curious to see what happens
Still stays in memory.

I'm using DX 9.0c.