Hi Nicolai,
On Tue, Jul 8, 2014 at 7:19 AM, Nicolai Hess <[email protected]> wrote: > I want to create a process doing some work and call #changed on a Morph. > I want to start/suspend/resume or stop this process. > But sometimes, suspending the process locks the UI-Process, > and I don't know why. Did I miss something or do I have to care when to > call suspend? > > Wrapping the "morph changed" call in > UIManager default defer:[ morph changed]. > Does not change anything. > > Here is an example to reproduce it. > Create the process, > call resume, call supsend. It works, most of the time, > but sometimes, calling suspend locks the ui. > > p:=[[true] whileTrue:[ Transcript crShow: (DateAndTime now asString). 30 > milliSeconds asDelay wait]] newProcess. > p resume. > p suspend. > If you simply suspend this process at random form a user-priority process you'll never be able to damage the Delay machinery you're using, but chances are you'll suspend the process inside the critical section that Transcript uses to make itself thread-safe, and that'll lock up the Transcript. ThreadSafeTranscript>>nextPutAll: value accessSemaphore critical: [stream nextPutAll: value]. ^value So instead you need to use a semaphore. e.g. | p s wait | s := Semaphore new. p:=[[true] whileTrue:[wait ifTrue: [s wait]. Transcript crShow: (DateAndTime now asString). 30 milliSeconds asDelay wait]] newProcess. wait := true. 30 milliSeconds asDelay wait. wait := false. s signal etc... HTH regards > Nicolai > -- best, Eliot
