For completeness, without the overengineering
EnableExplicit
Enumeration
#WINDOW
#TEXT
EndEnumeration
Enumeration #PB_Event_FirstCustomValue
#MESSAGE
EndEnumeration
Procedure AddMessagesThread(*notused)
Protected i, *buffer.String
Repeat
Delay(100)
i + 1
*buffer = AllocateStructure ...
Search found 86 matches
- Wed Jul 16, 2025 7:41 pm
- Forum: Coding Questions
- Topic: using semaphores in threads and TrySemaphore(Semaphore)
- Replies: 13
- Views: 417
- Wed Jul 16, 2025 7:27 pm
- Forum: Coding Questions
- Topic: using semaphores in threads and TrySemaphore(Semaphore)
- Replies: 13
- Views: 417
Re: using semaphores in threads and TrySemaphore(Semaphore)
For your second example you need no lists and no Mutex.
In the thread allocate a buffer, poke a string into it and send it by PostEvent() to the window queue.
In the window queue pick the buffer, peek the string and free the memory.
Nothing can collide here
Correct. I just wanted to avoid ...
- Wed Jul 16, 2025 1:40 pm
- Forum: Coding Questions
- Topic: using semaphores in threads and TrySemaphore(Semaphore)
- Replies: 13
- Views: 417
Re: using semaphores in threads and TrySemaphore(Semaphore)
Here is another example where we instead of using a semaphore we use PostEvent() to send an event
EnableExplicit
Global NewList messages.s()
Global mutex
Enumeration
#WINDOW
#TEXT
EndEnumeration
Enumeration #PB_Event_FirstCustomValue
#MESSAGE
EndEnumeration
Procedure AddMessagesThread ...
EnableExplicit
Global NewList messages.s()
Global mutex
Enumeration
#WINDOW
#TEXT
EndEnumeration
Enumeration #PB_Event_FirstCustomValue
#MESSAGE
EndEnumeration
Procedure AddMessagesThread ...
- Wed Jul 16, 2025 12:59 pm
- Forum: Coding Questions
- Topic: using semaphores in threads and TrySemaphore(Semaphore)
- Replies: 13
- Views: 417
Re: using semaphores in threads and TrySemaphore(Semaphore)
Here is an example of using TrySemaphore() within the main event loop that we don't want to block
EnableExplicit
Global NewList messages.s()
Global mutex
Global semaphore
Enumeration
#WINDOW
#TEXT
EndEnumeration
Procedure AddMessagesThread(*notused)
Protected i
Repeat
Delay(1000)
i + 1 ...
EnableExplicit
Global NewList messages.s()
Global mutex
Global semaphore
Enumeration
#WINDOW
#TEXT
EndEnumeration
Procedure AddMessagesThread(*notused)
Protected i
Repeat
Delay(1000)
i + 1 ...
- Mon May 12, 2025 10:33 am
- Forum: Coding Questions
- Topic: Exporting procedures when compiling against static library
- Replies: 1
- Views: 470
Re: Exporting procedures when compiling against static library
I managed to get it working for the original ASM backend by adding this line.
!public _Procedure0 as 'multiplier'
I figured this out by digging around in the forum and looking at the asm output.
To my limited understanding, by exporting multiplier with ProcedureDLL we get a symbol called ...
!public _Procedure0 as 'multiplier'
I figured this out by digging around in the forum and looking at the asm output.
To my limited understanding, by exporting multiplier with ProcedureDLL we get a symbol called ...
- Sun May 11, 2025 1:54 pm
- Forum: Coding Questions
- Topic: Exporting procedures when compiling against static library
- Replies: 1
- Views: 470
Exporting procedures when compiling against static library
I wonder if this is possible with PureBasic, the idea is that create a static library in another language and to compile that with PureBasic to a binary and avoid any extra dynamic dll files. The static library exports functions that PureBasic imports but the static library also imports procedures ...
- Mon Feb 03, 2025 4:16 pm
- Forum: Coding Questions
- Topic: #PB_Any object result values after PB 6.20
- Replies: 17
- Views: 4585
Re: #PB_Any object result values after PB 6.20
What does an administrative user do with these ids? The administrative user cannot really share these with anyone, like over the phone, because they are local to his running instance.
Thus one solution is to remap these numbers with your own Map where you can use any sequence you like as long as ...
Thus one solution is to remap these numbers with your own Map where you can use any sequence you like as long as ...
- Wed Dec 25, 2024 1:35 pm
- Forum: Off Topic
- Topic: Happy Christmas
- Replies: 17
- Views: 10078
Re: Happy Christmas
God Jul from Sweden!
- Tue Nov 12, 2024 2:58 pm
- Forum: Off Topic
- Topic: SQLite open database question
- Replies: 16
- Views: 6261
Re: SQLite open database question
About your database schema, do you store any large blobs together with other columns? If you do consider either store on blob directly on disk or have blobs in separate table. This helps performance when querying and updating tables by moving blobs to separate table.
Check you indexes, typically a ...
Check you indexes, typically a ...
- Tue Nov 12, 2024 2:38 pm
- Forum: Off Topic
- Topic: SQLite open database question
- Replies: 16
- Views: 6261
Re: SQLite open database question
Greetings
https://sqlite.org/whentouse.html
Client/Server Applications
If there are many client programs sending SQL to the same database over a network, then use a client/server database engine instead of SQLite. SQLite will work over a network filesystem, but because of the latency ...
https://sqlite.org/whentouse.html
Client/Server Applications
If there are many client programs sending SQL to the same database over a network, then use a client/server database engine instead of SQLite. SQLite will work over a network filesystem, but because of the latency ...
- Mon Oct 14, 2024 1:53 pm
- Forum: Coding Questions
- Topic: FreeStructure() crash
- Replies: 39
- Views: 5086
Re: FreeStructure() crash
Antivirus software? Faulty RAM memory sticks?
- Mon Oct 14, 2024 1:19 pm
- Forum: Coding Questions
- Topic: FreeStructure() crash
- Replies: 39
- Views: 5086
Re: FreeStructure() crash
I do not use threads. Also, the crash at AddElement() does not concern the same view or the same controls (as the crash related to FreeStructure()).
You write that you use PB 6.12, which was released recently, but also that this code has worked for months. Tried compiling your program on an ...
- Mon Oct 14, 2024 1:11 pm
- Forum: Coding Questions
- Topic: FreeStructure() crash
- Replies: 39
- Views: 5086
Re: FreeStructure() crash
I do not use threads. Also, the crash at AddElement() does not concern the same view or the same controls (as the crash related to FreeStructure()).
You write that you use PB 6.12, which was released recently, but also that this code has worked for months. Tried compiling your program on an ...
- Mon Oct 14, 2024 1:08 pm
- Forum: Coding Questions
- Topic: FreeStructure() crash
- Replies: 39
- Views: 5086
Re: FreeStructure() crash
It is always important to check return values for every procedure call that has one and if fail log that somewhere and graciously abort whatever you are doing.tored wrote: Mon Oct 14, 2024 12:53 pm Probably unlikely, but both AllocateStructure() and AddElement() can fail, check that.
- Mon Oct 14, 2024 1:02 pm
- Forum: Coding Questions
- Topic: FreeStructure() crash
- Replies: 39
- Views: 5086
Re: FreeStructure() crash
Probably unlikely, but AddElement() can fail, check that.
It does sometimes yes! What is the link then? It used to actually crash, then I restarted my computer (or did something else...?), and now FreeStructure() is the one that crashes all the time instead. AddElement() is in a different ...