multiple tasks

Community Forums/Monkey2 Talk/multiple tasks

skid(Posted 2015) [#1]
I was wondering if there was perhaps already a way in which multitasking could be implemented in monkey2.

Instead of a multi threading use case, I am more after a situation where my OnUpdate callback can "Run Until Yield" a number of disparate tasks.


Steve Ancell(Posted 2015) [#2]
I just tried and it errors like crazy, AKA it don't work the way I did it at least.


Strict
Import mojo




Function Main:Int()
	Local thread1:C_App
	Local thread2:C_App
	Local thread3:C_App
	Local thread4:C_App
	
	
	thread1 = New C_App("1'st thread")
	thread2 = New C_App("2'nd thread")
	thread3 = New C_App("3'rd thread")
	thread4 = New C_App("Hey Freddy!, look at all them Freds")
	
	Return 0
	
End




Class C_App extends App
	Field message:String
	
	
	Method OnCreate:Int()
		
		Return 0
		
	End
	
	
	Method OnUpdate:Int()
		
		Return 0
		
	End
	
	
	Method OnRender:Int()
		Cls
		DrawText(self.message, 10, 10)
		
		Return 0
		
	End
	
	
	Method New(message:String)
		Self. message = message
		
	End
	
End



GC-Martijn(Posted 2015) [#3]
See my previous topic pyramide of dead.

It would be cool to do some background stuff, that dont have any priority.
For example, creating some small special effects in the game.