0

Appropriate code provided below. I had this working once but have since messed up due to having to change some of the other code. Can't figure out what I've done. The encrypt function creates a thread and makes a call to function EncryptProc to process one or more files. Once each file is completed it should print the name to a textctrl. In the codes current state it waits until all threads/files are processed before printing. It then prints evrything in one go. During processing the textctrl also completely disappears. Any help would be much appreciated as its starting to drive me nuts, lol.

---EDIT--- CODE REMOVED

Clinton Moffat
  • 211
  • 1
  • 2
  • 12

1 Answers1

1

There should be no GUI access from within threads - in your case EncryptProc is writing to the text control directly - you need to either:

  1. Use CallAfter in the thread to update the text control after the thread exits or
  2. Raise custom event an event in the thread that carries the file name information and have a hander in the main thread that updates the text control on receiving the event.
Steve Barnes
  • 27,618
  • 6
  • 63
  • 73
  • Hi Steve. I have updated the code above , now using CallAfter. Still causes the same problem. Any ideas? – Clinton Moffat Aug 11 '13 at 20:59
  • Steve, I should add. Just tried removing all instances that print to textctrl and ran the program again. textctrl still completely disappears until files have been processed. Clinton. – Clinton Moffat Aug 11 '13 at 21:21
  • Hi Steve. All sorted now. I've updated the code above. Yes it was CallAfter that fixed the job for me. Thanks very much! Clinton. – Clinton Moffat Aug 11 '13 at 21:58