'UWP Delayed updates to Textbox using TraceListener
I have a tracelistener:
public class WindowTraceListener : System.Diagnostics.TraceListener
{
Model.TraceListener _value;
public WindowTraceListener(Model.TraceListener value)
{
_value = nessusToChecklist;
}
public override void Write(string message)
{
_value.TraceOutput += message;
}
public override void WriteLine(string message)
{
_value.TraceOutput += (message + Environment.NewLine);
}
}
And a POCO:
public class TraceListener: ObservableRecipient
{
private string _TraceOutput;
public string TraceOutput
{
get => _TraceOutput;
set => SetProperty(ref _TraceOutput, value, true, "TraceOutput");
}
}
Bound to a textbox:
<Grid Grid.Row="2" BorderBrush="Gray" BorderThickness="2" Margin="10,0">
<ScrollViewer Name ="scrollTraceOutput" >
<TextBox Name="txtTraceOutput" TextWrapping="Wrap" Text="{Binding TraceListener.TraceOutput, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" TextChanged="TextBox_TextChanged" ></TextBox>
</ScrollViewer>
</Grid>
The problem is updates to the textbox are delayed and do not happen in realtime. I don't think I have a GUI thread issue, because if the process is long enough, updates to occur during processing. I just want the updates to occur faster.
For example, some processing has a ... and I want the "." to appear as it is traced.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
