Click here to Skip to main content
15,033,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello
I have written c# project about similarity between tow sin curve and it hasn't any error and compile
but it doesn't work and my form hang up!
i have used 3 function in my form and when click on one button it should execute them!
in my functions i have used array and the collection(list of double values)
should i use class ????

please help me

one of mu function is like below:


C#
private void ASCI4(double[] x, int width)
     {
         double[] up = new double[width];
         double[] lp = new double[width];
         double[] ud = new double[width];
         double[] ld = new double[width];
         for(int i=0;i<width;i++)
         {
          up[i]=x[i]+0.25;
             UP.Add(up[i]);

          lp[i]=x[i]-0.25;
             LP.Add(lp[i]);

          ud[i]=x[i]+0.5;
             UD.Add(ud[i]);

          ld[i] = x[i] - 0.5;
              LD.Add(ld[i]);
         }
         foreach (double up1 in UP)
         {
             foreach (double ud1 in UD)
             {
                 foreach (double lp1 in LP)
                 {
                     foreach (double ld1 in LD)
                     {
                         foreach (Point v1 in V)
                         {
                             if ((v1.Y > lp1) & (v1.Y < up1))
                                 RP.Add(v1.Y);

                             else if ((v1.Y < ld1) | (v1.Y > ud1))
                                 RN.Add(v1.Y);
                             else if (((v1.Y >= ld1) & (v1.Y <= lp1)) | ((v1.Y >= up1) & (v1.Y <= ud1)))
                                 RZ.Add(v1.Y);
                         }
                     }
                 }
             }
         }
     }


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 21-Jun-13 22:20pm
v2

1 solution

You are surprised?
I'm not.

I don't know what value you are passing through as the width, but you then proceed to nest loops that will be at least width^5 iterations of the inner loop. (More, probably, since you don't clear your class level lists before you add new elements, and we can't see the number of elements in V) So, if your width is 5, then your inner loop is executed 3125 times. If it is 20, then it;'s 3,200,000 times round, and so forth, each time adding elements to a list...

Your form will do nothing until all iterations are complete. There are things you can do to prevent that, but first I think you need to look at this and work out if that is what you actually intended...


"onemore question
how can i send a textbox value from one form to another form and assign tetbox value to one variable???"



Depends on the relationship between the forms.
You don't send the textbox, you send the Text property string and let the other form decide what to do with it.
Have a look at these: one of them will describe the relationship and explain what to do.
Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]
   
v2
Comments
pegah67 22-Jun-13 7:41am
   
what should i do for solve this problem!!!
now that i'm showing again at my codes i see you're right!!!
that all Comparisons are neccessary and shuld be done in my project!!!!!
please help me
thanks!!
OriginalGriff 22-Jun-13 7:46am
   
Then the only thing you can do is move them into a different thread.
Try a BackgroundWorker
http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx
The link includes an example.
pegah67 22-Jun-13 8:48am
   
i'm beginner it's too hard for me :(
one more question:
i have an double array and want to draw sin curve with vlue of array's elements
how can i do this??
OriginalGriff 22-Jun-13 9:33am
   
Read the link - the example is pretty clear, and it's not that complex! It's probably half a dozen lines of code, is all.

Drawing a graph is harder than using threads! But this is probably where you want to start:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datavisualization.charting.chart.aspx
pegah67 23-Jun-13 2:27am
   
thank you for your help :)
OriginalGriff 23-Jun-13 3:20am
   
You're welcome!
OriginalGriff 23-Jun-13 6:37am
   
Answer updated.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900