Resolved one reference type not updating

aronmatthew

Well-known member
Joined
Aug 5, 2019
Messages
65
Programming Experience
Beginner
Here a sub set from _shelters is added to groupList. Then each reference in groupList is tagged to its own button. In this case when user clicks the button the reference is updated in the next dialog. When the dialog returns the value is not updating in _shelters, only when the value is the first index of groupList. I see no reasonable explanation for this one case only unless the cast from the button Tag could be causing a problem. Unless an exception is being thrown in the next dialog possibly. Will have to double check. But it's updating in the groupList so that's not likely either.

1745371773282.png


using first index of groupList here is a problem while the remaining indexes are updating ok in the same case
current value
1745372225252.png

groupList value
1745372292561.png

_sheltersValue
1745372348954.png
 
Last edited:
Recall that you are not writing code in C++. Here the reference to list[i] truly is a reference to a chunk of memory that exists outside of the context of the memory of the list. So this code works just fine without having to worry about an incorrectly aliased pointer.:
C#:
public static void stackEmptyLastCallDates(_Lshelter list)
{
    for(int i=0;i<list.Count;i++)
    {
        if (_Edate.isEmpty(list[i].LastCall))
        {
            _shelter temp = list[i];
            list.RemoveAt(i);
            list.Insert(0, temp);
        }
    }
}

Even if you had an inopportune garbage collection between the time RemoveAt() and Insert() is called, the old reference by list[i] won't be garbage collected because temp is holding a reference.
 
Recall that you are not writing code in C++. Here the reference to list[i] truly is a reference to a chunk of memory that exists outside of the context of the memory of the list. So this code works just fine without having to worry about an incorrectly aliased pointer.:
C#:
public static void stackEmptyLastCallDates(_Lshelter list)
{
    for(int i=0;i<list.Count;i++)
    {
        if (_Edate.isEmpty(list[i].LastCall))
        {
            _shelter temp = list[i];
            list.RemoveAt(i);
            list.Insert(0, temp);
        }
    }
}

Even if you had an inopportune garbage collection between the time RemoveAt() and Insert() is called, the old reference by list[i] won't be garbage collected because temp is holding a reference.

Right just is bound by the advanced built structure who knows what is. I wasn't aware of the move method just was in the process of driving this beta version on real streets. In panic to continue the journey I hocked that method together. Just drving this application is a dedicated task indeed especially in this case where the data set is completely defiled by the service sheriff's.
 
Dang only problem now the last call date sort method no sorting empty date to top although looks like the date compare should be sorting empty here is updated version


C#:
 public static int compare(_date lh, _date rh)
 {
     int lm = 0;
     int ld = 0;
     int ly = 0;

     int rm = 0;
     int rd = 0;
     int ry = 0;

     if(!_Edate.isEmpty(lh))
     {
        lm=int.Parse(lh.Month);
        ld= int.Parse(lh.Day);
        ly=int.Parse(lh.Year);

     }
     if (!_Edate.isEmpty(rh))
     {
       rm=int.Parse(rh.Month);
       rd=int.Parse(rh.Day);
       ry=int.Parse(rh.Year);

     }
     if (ly < ry)
         return -1;
     else if (ly > ry)
         return 1;
     else if (lm < rm)
         return -1;
     else if (lm > rm)
         return 1;
     else if (ld < rd)
         return -1;
     else if (ld > rd)
         return 1;
     else return 0;
          
 }
1745536692247.png
 
Last edited:
Back
Top Bottom