process still running after quitting the app

Just starting out? Need help? Post your questions and find answers here.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Hi PB - I'm pretty sure it was a (feeble? did I say that?) joke.
BERESHEIT
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post 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.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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.
BERESHEIT
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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.
BERESHEIT
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

Amazingly, the process still hasn't been killed after about 10 mins..
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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()
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post 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.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post 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()
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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?
BERESHEIT
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post 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.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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.
BERESHEIT
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post 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..]
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post 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?
Last edited by Xombie on Fri Aug 25, 2006 10:54 pm, edited 3 times in total.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

They're completely different technologies. ExamineKeyboard() uses DirectX whereas GetAsyncKeyState_() does not.
BERESHEIT
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post 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.
Post Reply