Possible Duplicate:
simulate cpu usage in mono for Android
Is there any other way to use more cpu rather than threading in mono/android application? please give some suggestion.
Thanks,
Possible Duplicate:
simulate cpu usage in mono for Android
Is there any other way to use more cpu rather than threading in mono/android application? please give some suggestion.
Thanks,
what a bizarre question. You can do all sorts of processor intensive things in the main thread. Read and write bitmap data, perform all sorts of calculations, etc. Why would you want to do this? And how much of the CPU are you hoping to tie up?
No idea what pupose it serves, but this doesn't use any worker threads and will suck up CPU pretty well:
[Activity(MainLauncher = true)]
public class PointlessActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
while(true) { }
}
}
You can implement a Canvas which invalidates everyTime like this:
private class Painter extends View{
ArrayList<Point> points;
public Painter(Context context){
super(context);
}
public void draw() {
points = new ArrayList<Point();
for (int i = 0; i < 10000; i++) {
//assign Points to the array
Point p = new Point();
p.x = 10;
p.y = 30;
points.add(p);
}
nameOfTheInstancePainter.invalidate();
}
@Override
protected void onDraw(Canvas c) {
for (int i = 0; i < 10000; i++) {
//paint aaaall the points
}
nameOfTheInstancePainter.invalidate(); //that will cause the ReDraw of everything everytime
}
}
Oh, by the way, painting a canvas use different threads, that's why I did this code !