How can I force my app to update the content page before executing a specific instruction.

NickprovsNickprovs USMember ✭✭
edited November 2017 in Xamarin.iOS

My app calculates a set of data points, graphs it, and then plays the sound generated by those data points. After setting the bindingcontext for the graph... I assume the graph updates, and then I play a generated sound.

This is how my app behaves in android. But on the iOS simulator, my app doesn't wait for my graph to render before playing the sound. This is an issue because the math required to generate these points takes up to a few seconds and I don't want the sound to play before the graph is displayed. This is the relevant portion of my code.

                for (int x = 0; x < totalNumberOfPoints; x++)

                    tau = tcoal - x * stepSize; //x*stepSize is time we're currently at in seconds in graph

                    eye = -2 * Math.Pow(5 * chirpMass, (-5 / 8f)) * Math.Pow((tau), (5 / 8f));
                    //adding the points based x,y to the series
                    xpoint = x * stepSize;
                    ypoint = 1 * Math.Pow((tauEND / tau), 1 / 4f) * Math.Cos(eye);
                    datas.Add(new ChartDataPoint(xpoint, ypoint));

                this.BindingContext = new SFDataSet(datas);

                string filePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "/tone.wav";
                //string filePath = Android.OS.Environment.ExternalStorageDirectory.Path + "/tone.wav"; //For Testing Purposes Only... a visible path

                if (startFrequency < endFrequency)
                    WaveGenerator wave = new WaveGenerator(WaveExampleType.Circular, audioDataPoints, tstop, (uint)totalNumberOfPoints); //The 0 is for amplitude. User input not actually used in circular binary. Always max (32760).
                    using (var file = File.OpenRead(lastFilePath))
                    mass1IntLast = mass1Int;
                    mass2IntLast = mass2Int;
                    lastFilePath = filePath;
Sign In or Register to comment.