Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, this is my first post here. I hope you can help me.

All my problems begun with below procedure,

C#
private void EntityManager(uint _index, DataRow _cachedrow)
        {
            while (_index < Controls.Length)
            {
                //Show control at UI
                this.InfereControlContainer(_index);

                //Wait for user's input
                this.SyncEvent.WaitOne();

                //Store current value in the row
                _cachedrow[Controls[_index].Name] = Controls[_index].LastValue;

                //Based on user's input, this method determines
                //what is the next control to show 
                uint _nexthop = NextHop(_index);

                //Control can be "grouped", so this while permits the
                // value nesting as much as MaxCycle control property
                uint current = 1;
                while (current < Controls[_index].LoopHorizon.MaxCycle)
                {
                    current++;

                    //Recursive operation to nest previous control values
                    EntityManager(_nexthop, _cachedrow);

                    //Of course, stop if _nexthop is out of array boundaries
                    if (_nexthop > Controls.Length) { return; }

                    //the MinCycle property 
                    if (current > Controls[_index].LoopHorizon.MinCycle)
                    {
                        if (MessageBox.Show("Do you want to close this group?", Controls[_index].Description,
                            MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                        { return; }
                    }
                }

                //Move forward
                _index = _nexthop;
            }

            //Store point
            this.InsertRow(_cachedrow);
        }


Output example (well, at least is what I want):

["COLUMN_A"]["COLUMN_B"]["COLUMN_C"]["COLUMN_D"]["COLUMN_E"]
 VAL1       VAL2        X            Y           Z
 VAL1       VAL2        A            B           C
 VAL1       VAL2        Foo          Faa         Fee


The problem-- there might be an error in that thread stuff or in the recursive procedure that suddenly produces "undesired results", say, in some rare cases the buffered inner (wrapped) row values just disappear so I only receive partial information in what should be a full filled row.

The rare thing happen when I debug the code, say, if I add interruption points in certain code areas, magically everything goes fine.

What I'm doing wrong?

Thanks in advance for your help. Ed.
Posted

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