Page 1 of 1

Posted: Mon Mar 04, 2002 1:02 am
by BackupUser
Restored from previous forum. Originally posted by El_Choni.

Hi,

I have a little problem with a thread. It's only called when it's supposed to end. This is the calling code:

Code: Select all

                Gosub OpenXpm
                ProgressExitCode = 0
                ThreadID = CreateThread(@Progress(), "Xpm")
                Gosub Xpm2Bmp
                ProgressExitCode = 1
                Gosub ShowImage
The procedure is only called when returning from Xpm2Bmp, and inmediatly ended. This is the thread procedure:

Code: Select all

Procedure Progress(format.s)
  done = 0
  If OpenPopUpWindow(2, WindowX()+(WindowWidth()>>1)-128, WindowY()+(WindowHeight()>>1)-32, 256, 64, "Converting image")
    If CreateGadgetList(PopUpWindowID())
      TextGadget(2, 16, 28, 80, 20, format+" --> Bmp")
      ProgressBarGadget(3, 16, 48, 80, 32, 0, 100)
      SetGadgetState(3, done)
    EndIf
  EndIf
  Repeat
    If ProgressExitCode = 1
      done = 100
    Else
      done = Round((Seeker/BmpSize)*100, 0)
      SetGadgetState(3, done)
      Sleep_(20)
    EndIf
  Until done = 100
  ClosePopUpWindow(2)
EndProcedure
This code works if called (uses the PopUpWindow library, yes I know, gadgets are not placed correctly). If you put a requester at the beginning, you'll see it after returning from Xpm2Bmp, not before, as it should.

Any ideas are welcome (come back, Fred! XD),

Bye,

El_Choni

Posted: Mon Mar 04, 2002 2:09 pm
by BackupUser
Restored from previous forum. Originally posted by tranquil.

Hi El_Choni,

I dont understand your problem due to a lack of my bad english I think. :-(
If you want to end the Thread by setting the var ProgressExitCode=1 you have to share this Variable in the ThreadProcedure.

Share ProgressExitCode

Possible your problem is fixed now, if not, tell us more. :)

Cheers
Mike

PS: I heard that you helped MrVain a lot of due to his Project, I want send a big "thanks" to you back for helping him!!


Tranquilizer/ Secretly!
Registred PureBasic User