protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params) { double xmin = -2; double xmax = 1.0; double ymin = -1.5; double ymax = 1.5; MandelbrotCalculator mc = new MandelbrotCalculator(_width, _height, _maxIterations, xmax, xmin, ymax, ymin); WorkOrderList.NewRequest(this, _width, _height); List <CommPackage> cpList = JsonConvert.DeserializeObject <List <CommPackage> >(mc.SubmitWorkOrders()); _progressDialog.Max = cpList.Count(); foreach (CommPackage cp in cpList) { WorkOrderList.SubmitNewWorkOrder(cp); } StartTime = DateTime.Now; while (!_complete) { // do nothing Thread.Sleep(new TimeSpan(0, 0, 1)); } EndTime = DateTime.Now; return(true); }
protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params) { double xmin = -2; double xmax = 1.0; double ymin = -1.5; double ymax = 1.5; MandelbrotCalculator mc = new MandelbrotCalculator(_width, _height, _maxIterations,xmax,xmin,ymax,ymin); WorkOrderList.NewRequest(this, _width, _height); List<CommPackage> cpList = JsonConvert.DeserializeObject<List<CommPackage>>(mc.SubmitWorkOrders()); _progressDialog.Max = cpList.Count(); foreach (CommPackage cp in cpList) { WorkOrderList.SubmitNewWorkOrder(cp); } StartTime = DateTime.Now; while (!_complete) { // do nothing Thread.Sleep(new TimeSpan(0, 0, 1)); } EndTime = DateTime.Now; return true; }
public static int[][] ProcessRequest(int xStart, int yStart, double xMax, double xMin, double yMax, double yMin, int height, int width, int xChunkSize, int yChunkSize, int maxIterations) { int[][] pixelColours = new int[xChunkSize][]; for (int x = xStart; x < (xStart + xChunkSize); x++) { pixelColours[x - xStart] = new int[yChunkSize]; for (int y = yStart; y < (yStart + yChunkSize); y++) { pixelColours[x - xStart][y - yStart] = MandelbrotCalculator.GetColourOfPixel(x, y, xMax, xMin, yMax, yMin, height, width, maxIterations); } } return(pixelColours); }
void button_Click(object sender, EventArgs e) { EditText maxIterations = FindViewById <EditText>(Resource.Id.maxIterations); try { int maxIterationsNo = int.Parse(maxIterations.Text); if (maxIterationsNo > 0 && maxIterationsNo <= 100000) { if (FindViewById <RadioButton>(Resource.Id.cloudComputation).Checked) { new AsyncGetResultsTask(this, this, FindViewById <ImageView>(Resource.Id.mandelbrotImgView), 300, 300, maxIterationsNo).Execute(); } else { DateTime startTime = DateTime.Now; ImageView _imgView = FindViewById <ImageView>(Resource.Id.mandelbrotImgView); double xmin = -2; double xmax = 1.0; double ymin = -1.5; double ymax = 1.5; MandelbrotCalculator mc = new MandelbrotCalculator(300, 300, maxIterationsNo, xmax, xmin, ymax, ymin); List <CommunicationResources.PixelColour> pixColList = mc.GenPixelColourList(); DateTime colourGenEndTime = DateTime.Now; _imgView.SetImageBitmap(mc.GetBitmap(pixColList)); new AlertDialog.Builder(this) .SetTitle("Mandelbrot generated") .SetMessage("Success! Time taken(s) - Col Gen: " + colourGenEndTime.Subtract(startTime).TotalSeconds + " Draw time: " + DateTime.Now.Subtract(colourGenEndTime).TotalSeconds) .Show(); } } else { new AlertDialog.Builder(this).SetMessage("Max iterations must greater than 0 and less than or equal to 100,000").SetTitle("Error").Show(); } } catch (Exception) { new AlertDialog.Builder(this).SetMessage("Max iterations must be an integer").SetTitle("Error").Show(); } }
void button_Click(object sender, EventArgs e) { EditText maxIterations = FindViewById<EditText>(Resource.Id.maxIterations); try { int maxIterationsNo = int.Parse(maxIterations.Text); if (maxIterationsNo > 0 && maxIterationsNo <= 100000) { if (FindViewById<RadioButton>(Resource.Id.cloudComputation).Checked) { new AsyncGetResultsTask(this, this, FindViewById<ImageView>(Resource.Id.mandelbrotImgView), 300, 300, maxIterationsNo).Execute(); } else { DateTime startTime = DateTime.Now; ImageView _imgView = FindViewById<ImageView>(Resource.Id.mandelbrotImgView); double xmin = -2; double xmax = 1.0; double ymin = -1.5; double ymax = 1.5; MandelbrotCalculator mc = new MandelbrotCalculator(300, 300, maxIterationsNo, xmax, xmin, ymax, ymin); List<CommunicationResources.PixelColour> pixColList = mc.GenPixelColourList(); DateTime colourGenEndTime = DateTime.Now; _imgView.SetImageBitmap(mc.GetBitmap(pixColList)); new AlertDialog.Builder(this) .SetTitle("Mandelbrot generated") .SetMessage("Success! Time taken(s) - Col Gen: " + colourGenEndTime.Subtract(startTime).TotalSeconds + " Draw time: " + DateTime.Now.Subtract(colourGenEndTime).TotalSeconds) .Show(); } } else { new AlertDialog.Builder(this).SetMessage("Max iterations must greater than 0 and less than or equal to 100,000").SetTitle("Error").Show(); } } catch (Exception) { new AlertDialog.Builder(this).SetMessage("Max iterations must be an integer").SetTitle("Error").Show(); } }