Note that there are some explanatory texts on larger screens.

plurals
  1. POBackground worker not setting `e.result`
    primarykey
    data
    text
    <p><strong>Overview:</strong><br> I have several background workers used to import data into an access database and then carry out some calculations. I pass a <code>hashtable</code> of arguments between the background workers using <code>e.Argument</code> and <code>e.Result</code>. This hashtable contains data about the files that are to be imported.</p> <p><strong>Problem:</strong><br> On one of my background workers (about fourth in the process), I can't set <code>e.result</code>, instead it stays as <code>nothing</code>, which then causes an error in the worker completed subroutine. As far as I can tell this is a duplicate of all of my code for my other workers so there is no reason why this one won't set.</p> <p><strong>Code:</strong> </p> <pre><code>Private Sub bwConditionCalc_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bwConditionCalc.DoWork Dim Dates As New List(Of Date) Dim Arguments As Hashtable Arguments = e.Argument 'Worker Content----------- Arguments("VariablesCalculated") = VariablesCalculated LabelString = "Tasks Complete..." e.Result = Arguments End Sub Private Sub bwConditionCalc_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bwConditionCalc.RunWorkerCompleted Dim Arguments As New Hashtable Arguments = e.Result ' Check if missed calc Params can now be calculated/scaled 'The Error occurs here--------------------- If Not Arguments("VariablesCalculated") = 0 Then Arguments("SchedCalculateData") = True Arguments("SchedConditionalCalc") = True End If prgFieldMaster.Value = 0 lblStatus.Text = LabelString RunWorkSchedule(Arguments) End Sub </code></pre> <p><strong>EDIT:</strong><br> The <code>DeepCopy</code> routine returns a hashtable, and was put there as an attempted fix. I still get the same Error without <code>Deep Copy</code> which I will remove from the quoted code to now.</p> <p><strong>EDIT - <code>e.error</code> handle</strong><br> Private Sub bwConditionCalc_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bwConditionCalc.RunWorkerCompleted</p> <pre><code> If (e.Error IsNot Nothing) Then MessageBox.Show(e.Error.Message) End If Dim Arguments As New Hashtable Arguments = e.Result ' Check if missed calc Params can now be calculated/scaled If Not Arguments("VariablesCalculated") = 0 Then Arguments("SchedCalculateData") = True Arguments("SchedConditionalCalc") = True End If prgFieldMaster.Value = 0 lblStatus.Text = LabelString RunWorkSchedule(Arguments) End Sub </code></pre> <p><strong>EDIT - Worker Schedule</strong> </p> <p>The sub below is called by a starter subroutine that creates the original Arguments Hashtable. After each worker completes it then calls this sub again in the worker completed rountine. The cycle before the routine causing this called, I am calling <code>Importchecker</code>, <code>ImportData</code>, <code>CalculateData</code> then <code>ConditionalCalc</code>.</p> <pre><code> Public Sub RunWorkSchedule(ByVal Arguments As Hashtable) Me.Refresh() 'Do nothing if worker is busy If bwCalcParam.IsBusy = True Or bwScaleData.IsBusy = True Or bwImportWriter.IsBusy = True Or bwColumnAdder.IsBusy = True Or bwConditionCalc.IsBusy = True Or bwDeleteParameterbyUpload.IsBusy Or bwDeletebyParameterOrCondition.IsBusy Or bwEventCalc.IsBusy Or bwImportChecker.IsBusy Or bwAddRawTables.IsBusy Then Exit Sub DataSchedRunning = True 'Scheduled tasks: If Arguments("SchedUploadDelete") = True Then Arguments("SchedUploadDelete") = False lblStatus.Text = "Deleting Data by Upload" bwDeleteParameterbyUpload.RunWorkerAsync(Arguments) Exit Sub End If If Arguments("SchedDeletebyParameterOrCondition") = True Then Arguments("SchedDeletebyParameterOrCondition") = False lblStatus.Text = "Deleting Data by Parameter Or Condtion" bwDeletebyParameterOrCondition.RunWorkerAsync(Arguments) Exit Sub End If If Arguments("SchedAddRawTables") = True Then Arguments("SchedAddRawTables") = False lblStatus.Text = "Adding raw data tables to the Database..." bwAddRawTables.RunWorkerAsync(Arguments) Exit Sub End If If Arguments("SchedColumnAdder") = True Then Arguments("SchedColumnAdder") = False lblStatus.Text = "Adding Columns to the Database..." bwColumnAdder.RunWorkerAsync(Arguments) Exit Sub End If If Arguments("SchedImportChecker") = True Then Arguments("SchedImportChecker") = False lblStatus.Text = "Preparing to check Import Files..." bwImportChecker.RunWorkerAsync(Arguments) Exit Sub End If If Arguments("SchedImportData") = True Then Arguments("SchedImportData") = False lblStatus.Text = "Preparing to Import data..." bwImportWriter.RunWorkerAsync(Arguments) Exit Sub End If If Arguments("SchedCalculateData") = True Then Arguments("SchedCalculateData") = False lblStatus.Text = "Preparing to Calculate data..." bwCalcParam.RunWorkerAsync(Arguments) Exit Sub End If If Arguments("SchedConditionalCalc") = True Then Arguments("SchedConditionalCalc") = False lblStatus.Text = "Preparing to Calculate Conditional Data..." bwConditionCalc.RunWorkerAsync(Arguments) Exit Sub End If If Arguments("SchedScaleData") = True Then Arguments("SchedScaleData") = False lblStatus.Text = "Preparing to Scale Data..." bwScaleData.RunWorkerAsync(Arguments) Exit Sub End If If Arguments("SchedEventCalc") = True Then Arguments("SchedEventCalc") = False lblStatus.Text = "Preparing to Calculate Events" bwEventCalc.RunWorkerAsync(Arguments) Exit Sub End If Finish: If SchedNewArgument = True Then timNextTask.Enabled = True End If lblStatus.Text = "Tasks Complete" StatusStrip1.Refresh() DataSchedRunning = False 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