Does the windows callback operate like a seperate thread?
The reason I'm asking is that I access a linked list during both the main app and the callback.  At the beginning of the callback I save the current list position and restore it at the end.
If it operates like a thread though, this will not be enough.
If so, is there a safe way to access a linked list during the callback or do I have to use a signal/wait method?
-Anthony
			
			
									
									windows callback
- DoubleDutch
 - Addict

 - Posts: 3220
 - Joined: Thu Aug 07, 2003 7:01 pm
 - Location: United Kingdom
 - Contact:
 
windows callback
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
						https://reportcomplete.com <- School end of term reports system
- DoubleDutch
 - Addict

 - Posts: 3220
 - Joined: Thu Aug 07, 2003 7:01 pm
 - Location: United Kingdom
 - Contact:
 
Looks like it is dangerous to do this...
Anyhow solved it with a little help from the irc channel...
Here is the info, incase some of you have a similar problem:
The list is a structure of a hitem address and a string...
I make SubjectStart the address of the 1st element (if any)...
In the main program i simple use the list as normal, but if I'm deleting an element i wait until Unsafelist=#false before I do it.
If I clear the list I first clear SubjectStart then wait for Unsafelist to be #false.
I think this should be good enough to stop virtually anything going wrong.
			
			
									
									Anyhow solved it with a little help from the irc channel...
Here is the info, incase some of you have a similar problem:
The list is a structure of a hitem address and a string...
I make SubjectStart the address of the 1st element (if any)...
Code: Select all
; this is in the callback
If SubjectStart
  Unsafelist=#True
  hitem=*tvCD\nmcd\dwItemSpec
  addr=SubjectStart
  textaddr=0
  Repeat
    If PeekL(addr+8)=hitem         ; 1st item in structure
      textaddr=PeekL(addr+12)     ; 2nd item in structure
      If textaddr
        text$=PeekS(textaddr)
      Else
        textaddr=#True
        text$="@"   ; this is for me to see if something is wrong
      EndIf
    Else
      addr=PeekL(addr)       ; next item in list
    EndIf
  Until textaddr Or addr=0
  Unsafelist=#False
Else
  text$="$"  ; list is empty!
EndIf
If I clear the list I first clear SubjectStart then wait for Unsafelist to be #false.
I think this should be good enough to stop virtually anything going wrong.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
						https://reportcomplete.com <- School end of term reports system
- DoubleDutch
 - Addict

 - Posts: 3220
 - Joined: Thu Aug 07, 2003 7:01 pm
 - Location: United Kingdom
 - Contact:
 
What I should probabily do is make the flag turing on a critical section.  But it will effect system timers, etc...
Notice that I clear SubjectStart before I wait for the flag - thus there is a double protection here.
It seems to work okay, I made it run for quite a while in an extreme situation and nothing flagged up as wrong.
-Anthony
			
			
									
									Notice that I clear SubjectStart before I wait for the flag - thus there is a double protection here.
It seems to work okay, I made it run for quite a while in an extreme situation and nothing flagged up as wrong.
-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
						https://reportcomplete.com <- School end of term reports system
