[Pharo-project] Implementing a Timer: "newProcessWith: anArray" fails

nullPointer epicfan at gmail.com
Mon Oct 18 04:19:07 EDT 2010


Hi

I do implementing a easy Timer class. The purpose of timer is launch events
for UI thread and the process thread too when a interval of time is elapsed.

My problem is throwned when I call the message #newProcessWith: from
BlockClosure. I pass an array with a parameter, the instance of CLTimer
class, which is used in the Closure process for launc the events. A error of
not is valid the number of arguments is launched:

             'This block accepts 1 argument, but was called with 0
arguments.'

I don´t understand very good the problem. I have pass an array with one
element, and the Closure receives one parameter too...

Basically the code:

pvtGetNewProcessBlock

	^[:timer || intervalDelay |
		
		[timer enabled] whileTrue:[
		
			(Delay forMilliseconds: timer interval) wait. 

			timer enabled ifTrue:[
				
				timer raiseOnElapsedTimeForProcessThread: (timer getProcess).
				
				WorldState addDeferredUIMessage:[ 
					timer raiseOnElapsedTimeForUIThread: (timer getProcess) 
				].
			]
		].
	].


pvtStartProcess

    | processBlock |
    
    processBlock := self pvtGetNewProcessBlock.

    internalProcess := processBlock newProcessWith:{self}.
    internalProcess resume.



PD. Exists some complete doc with the way for work with threads in
Pharo/Squeak? I did see time ago a doc of Smalltalk processes, in french
language, but I don´t see in Google :(


http://forum.world.st/file/n2999831/CLTimer.st CLTimer.st 
-- 
View this message in context: http://forum.world.st/Implementing-a-Timer-newProcessWith-anArray-fails-tp2999831p2999831.html
Sent from the Pharo Smalltalk mailing list archive at Nabble.com.




More information about the Pharo-dev mailing list