ich erstelle vor meiner Hauptprogrammschleife einen thread.
diese soll dateien welche ich in eine globale liste hinzufüge downloaden.
ohne Thread hatte der download wunderbar geklappt.
Code: Alles auswählen
Global ThreadID = CreateThread(@EXAMINE_DOWNLOAD(),0)
wärend der hauptschleife prüfe ich den status:
Code: Alles auswählen
Debug IsThread(ThreadID)
vielleicht hat hier jemand einen tip für mich.
danke.
hier mal noch die prozedur:
Code: Alles auswählen
Procedure EXAMINE_DOWNLOAD(a.i)
If ListSize(TotalDownloads()) = 0
If ProgrammState = #Programm_preupdate
ProgrammState = #programm_checkgamefiles
Control_Hide(#CONTROL_TextCheckUpdate)
EndIf
If ProgrammState = #programm_download
ProgrammState = #programm_running
Control_Hide(#CONTROL_TextCheckUpdate)
;restore gui
Control_HideGroup(#Control_GroupTempGravity,#False)
Control_DisableGroup(#Control_GroupTempTitels,#False)
Control_Hide(#CONTROL_Navileft,#False)
Control_Hide(#CONTROL_Naviright,#False)
EndIf
Else
;Files anzeigen
;datei laden
;neue datei
If Not *http
NextElement(TotalDownloads())
*http = 0
*http = HTTPQuery_New(TotalDownloads()\path+"/"+TotalDownloads()\name)
If HTTPQuery_Open(*http)
Protected statuscode.i = HTTPQuery_GetStatuscode(*http)
; Check for valid statuscode
If statuscode >= 200 And statuscode < 300
*buffer = AllocateMemory(#DOWNLOAD_BUFFER)
CreateDirectory(TotalDownloads()\tpath)
fp = CreateFile(#PB_Any, TotalDownloads()\tpath +"\"+ TotalDownloads()\name)
If Not fp
Debug "file create error"
Else
Debug "file create"
TotalDownloads()\totalContentLength = HTTPQuery_GetTotalContentLength(*http)
TotalDownloads()\estimateStartTime = ElapsedMilliseconds()
TotalDownloads()\estimateStartBytes = 0
EndIf
Else
MessageRequester(#Gametitel,"error " + Str(statuscode) + " download von: " + TotalDownloads()\path+"/"+TotalDownloads()\name +" nicht möglich")
DeleteElement(TotalDownloads())
HTTPQuery_Close(*http)
HTTPQuery_Free(*http)
*http = 0
ProcedureReturn #True
EndIf
Else
HTTPQuery_Close(*http)
HTTPQuery_Free(*http)
*http = 0
EndIf
EndIf
If *http
If *buffer
If fp
temp = HTTPQuery_Read(*http, *buffer,#DOWNLOAD_BUFFER,#True)
WriteData(fp, *buffer, temp)
SET_DOWNLOAD_PROGRESS(100*HTTPQuery_GetProgress(*http),TotalDownloads()\name,Round((FilesToDownload-ListSize(TotalDownloads()))/FilesToDownload,#PB_Round_Nearest))
Debug "download"
;Datei zu ende neues element
If HTTPQuery_EOF(*http)
Debug "finish"
CloseFile(fp)
; Connection terminated before we finished normally?
If HTTPQuery_GetStatuscode(*http) < 0
EndIf
HTTPQuery_Close(*http)
HTTPQuery_Free(*http)
*http = 0
DeleteElement(TotalDownloads())
EndIf
Else
MessageRequester(#Gametitel,"Failed To create file: "+ TotalDownloads()\path+ "\" +TotalDownloads()\name+"")
;programmstate = #wait
;StatusBarText(0,0,"Failed to create file!")
EndIf
Else
HTTPQuery_Close(*http)
HTTPQuery_Free(*http)
*http = 0
EndIf
EndIf
EndIf
EndProcedure
