I found an article on mulithreaded apps, and downloaded the library. I used it on a few routines. Strangely enough the one that bogged down the most was when I convert a classic Basic routine to display a bunch of random circles on the screen... Eg. I have 2 threads each basically like this:
Sub C1a
Dim X,Y, r, T,C1 As Int
For T = 1 To 500
X = Rnd(0,Panel1.Width)
Y = Rnd(0,Panel1.Height)
r = Rnd(0,Panel1.Width / 2)
C1 = Colors.ARGB(Rnd(50,255),Rnd(0,255),Rnd(0,255),Rnd(0,255))
c.drawcircle(X,Y,r,C1,True,1.0)
Next
End Sub
The other thread is Sub C2a ... That's the one that seems to bog it down the most. I originally was trying to do 32000 circles, I broke it down into 2 threads each doing 16000 random circles. I tried using doevents and sleep, I tried doing an Activity.Invalidate to have it update the screen... Either way, with a loop of at least 1000 or so, I get the phone kinda bogged down for a few seconds not showing anything till it's completely done drawing, then it shows the menu bar and the circles... On the multi-threaded, the second thread finishes a few seconds later and more circles appear.
Then I do a moire pattern, and a circle pattern, and generate random boxes (each on their own activity). The moire pattern shows instantly, no problems with it:
Sub M1a
For T = 0 To X Step 2
c.DrawLine(T,0,X-T,Y,Colors.Cyan,1.0)
Next
End Sub
Sub M2a
For T = 0 To Y Step 2
c.DrawLine(0,T,X,Y-T,Colors.Cyan,1.0)
Next
End Sub
M1a and M2a are 2 threads for the demo. Each thread runs at the same time, so it draws the Horizontal and Vertical parts at the same time. Very fast too!
Sub chaser
Dim T As Int
x = 0
y = 0
For T = 1 To 20000
Lx = x
Ly = y
x = Rnd(0,Panel1.Width)
y = Rnd(0,Panel1.Height)
c.DrawLine(x,y,Lx,Ly,Colors.ARGB(255,0,T,0),5)
Next
End Sub
On Chaser, I tried to use a delay and erase the previous line. I'd love to have it draw the line, delay, erase, re-draw a new line. But using the delay command someone else posted, it either delays too quickly, or delays far too long. I either get no line (erasing it instantaneous) or I get draw a line, pause 3-4 minutes, draw another line... So I went with this... Instantaneous... And yup, I tried invalidate on that too....