Question: I am working on a multi-threaded app. I'm processing reports and keeping track of the number of reports in the current batch as well as the total number of reports processed. Whenever I update the counters, I also need to update a label on the GUI which, since the process is on a separate thread, requires a call to a delegate. Which one of these is the better way to go?

```

private void UpdateTotalCount(int newValue)
{
    totalCount = newValue;
    if (labelTotalCount.InvokeRequired)
        BeginInvoke((MethodInvoker) delegate() { 
            labelTotalCount.Text = "Total reports:" + totalcount; });
    else
        labelTotalCount.Text = "Total reports:" + totalcount;
}

```

or 

```

private int totalCount;
public int TotalCount
{
    get { return totalCount; }
    set {
        totalCount = value;
        if (labelTotalCount.InvokeRequired)
            BeginInvoke((MethodInvoker) delegate() { 
                labelTotalCount.Text = "Total reports:" + totalcount; });
        else
            labelTotalCount.Text = "Total reports:" + totalcount;
    }
}
```

**Edit:** Ok, third option.

```

private void UpdateTotalCountLabel()
{
    if (labelTotalCount.InvokeRequired)
        BeginInvoke((MethodInvoker) delegate() { 
            labelTotalCount.Text = "Total reports:" + totalcount; });
    else
        labelTotalCount.Text = "Total reports:" + totalcount;
}
// code elsewhere would look like this
totalCount++;
UpdateTotalCountLabel();
//or
totalCount+= curBatch.Length;
UpdateTotalCountLabel();

```

Answer: 
I think using the public accessors is better since it allows more maintanable code in case later on you need to change the way the total value is calculated. In that way, the users of the TotalValue property will not need to worry about your changes since these changes will not affect their code in any way.
I actually favor #1, since it clearly conveys that you are *doing* something, other than setting a field.

However, I agree with Mykola that your UI interaction **should not belong** to the same class that your backing logic does.