Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating progressbar from a background thread
    primarykey
    data
    text
    <p>I have a progressbar and its value is binded to a property:</p> <pre><code> &lt;ProgressBar x:Name="progressBar" Margin="0,2,0,0" Height="20" Value="{Binding CompassLogLoadPercent}" Foreground="Blue" Visibility="{Binding CompassLogLoadCompleted, Converter={StaticResource BooleanToVisibilityConverter}}" ToolTip="Loading"&gt; &lt;/ProgressBar&gt; </code></pre> <p>and the property:</p> <pre><code> public double CompassLogLoadPercent { get { return _compassLogLoadPercent; } private set { if (value != _compassLogLoadPercent) { _compassLogLoadPercent = value; NotifyPropertyChanged(); } } } </code></pre> <p>and in a seperate thread its value is updated:</p> <pre><code> for (int j = 0; j &lt; lines.Count(); j++) { ... CompassLogLoadPercent = ((double) j /lines.Count())*100; } </code></pre> <p>and the thread is created using TASK:</p> <pre><code>Task.Run(() =&gt; { LoadLogFile(fileName); }); </code></pre> <p>Why is progressbar not updating and how should I fix this?</p> <p><strong>UPDATE</strong>: <em>More Info</em></p> <p>Datacontext: (Im sure that the dataContext is Correct)</p> <pre><code>cLT.progressBar.DataContext = logSession; </code></pre> <p>and implementation of <code>INotifyPropertyChanged</code></p> <pre><code> public event PropertyChangedEventHandler PropertyChanged; protected virtual void NotifyPropertyChanged( [CallerMemberName] String propertyName = "") { PropertyChangedEventHandler eventHandler = PropertyChanged; PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload