Restored from previous forum. Originally posted by Andy.
When using several threads, is it then possible to access files, from within the threads, which were opened before calling the threads?
Andy
Threads and files...
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ricardo.
Its possible:Originally posted by Andy
When using several threads, is it then possible to access files, from within the threads, which were opened before calling the threads?
Andy
Code: Select all
Procedure ReadOpenedFile(FileNum.l)
UseFile(FileNum)
MessageRequester("string",ReadString(),0)
CloseFile(FileNum)
EndProcedure
If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,"Test")
CreateGadgetList(WindowID())
ButtonGadget(1,200,100,50,25,"Test")
Repeat
EventID=WaitWindowEvent()
Select EventID
Case #PB_EventGadget
Select EventGadgetID()
Case 1
If OpenFile(0,"somedata.txt");create a file and store some string
WriteString("1234567")
CloseFile(0)
EndIf
If OpenFile(1,"somedata.txt");open the file and call the procedure in a thread
ThreadID = CreateThread(@ReadOpenedFile(),1)
EndIf
EndSelect
EndSelect
Until EventID=#PB_EventCloseWindow
EndIf
End
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm