Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF BackgroundWorker - UI locks up trying to instantiate object from external class
    primarykey
    data
    text
    <p>I am trying to run a backgroundworker to load data from my DAL (which is available in another class). I want to keep the UI available and not have the "locked up" feel while the object is loading.</p> <p>When I create a simple backgroundworker and Sleep the UI stays responsive and my controls can be updated after the sleep. As soon as I replace the sleep with a call to instantiate the object from my DAL, the UI locks up. Is there someway I can instantiate this object using the background worked and keep the UI responsive?</p> <p>When the situation object is instantiated it could take several seconds for it to load completely, during this time is when the UI is locked up... It does eventually load just fine.</p> <pre><code>Private WithEvents backWork As New BackgroundWorker() Dim sit As Situation Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnLoad.Click backWork.RunWorkerAsync() End Sub Private Sub backWork_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles backWork.DoWork Load() End Sub Private Sub backWork_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles backWork.ProgressChanged lblLoading.Visibility = Visibility.Visible End Sub Private Sub backWork_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles backWork.RunWorkerCompleted tab1.DataContext = sit lblLoading.Visibility = Visibility.Hidden End Sub Private Sub Load() backWork.WorkerReportsProgress = True backWork.ReportProgress(1) sit = New Situation End Sub </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