编译问题的背景工作者

编译问题的背景工作者

本文介绍了编译问题的背景工作者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。

如果有人能为我解决这个问题,我将永远感激不尽!下面的代码是对更大应用程序的地名词典部分的初步尝试。它将位置信息读入DataGridView。代码在IDE中运行正常,但在编译时,它会在我尝试运行时挂起。数据加载和问题似乎在线附近 - Me.CumbriaDataBindingSource.ResetBindings(False)。 'beep'表示已达到RunWorkerCompleted代码。



控件是: -

两个按钮(btnStart,btnStop)

a label(lblStatus)

a datagridview(datagridview1),它通过向导绑定到Access数据库。



我是我确信我保持这段代码尽可能简单,以使其工作,并且事实上我已经做了我希望的一个简单的错误,这对我来说是一个教训。我找不到它。



IDE是VS2008,开发平台是32位XP



因为它很小,所以相关代码的整个部分如下所示。



Hi.
If anyone can resolve this for me I'll be eternally grateful! The code below is an initial attempt at a gazetteer section of a much larger application. It reads location information into a DataGridView. The code runs OK in the IDE but when compiled, it hangs when I attempt to run it. The data loads and the problem appears to be somewhere around the line - Me.CumbriaDataBindingSource.ResetBindings(False). The 'beep' indicates that the RunWorkerCompleted code is reached.

Controls are:-
two buttons (btnStart, btnStop)
a label (lblStatus)
a datagridview (datagridview1)which is bound to an Access database via the wizard.

I was convinced that I'd kept this code as simple as possible in order to get it working and the fact that I've made what I hope is a simple mistake aught to be a lesson to me. I just can't find it.

The IDE is VS2008 and the development platform is 32 bit XP

As it's quite small, the entire section of the code concerned is shown below.

Public Class Form1
  Private Sub Start_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
    'Clear the DataSet to allow the program to be re-run
    CumbriaDataSet.Clear()
    ' Disable the start button
    Me.btnStart.Enabled = False
    ' Enable to stop button
    Me.btnStop.Enabled = True
    ' Start the Background Worker
    BackgroundWorker1.RunWorkerAsync()
  End Sub

  Private Sub Stop_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
    ' Is the Background Worker still working?
    If BackgroundWorker1.IsBusy Then
      'Cancel It
      If BackgroundWorker1.WorkerSupportsCancellation Then
        BackgroundWorker1.CancelAsync()
        ' Enable to Start Button
        Me.btnStart.Enabled = True
        ' Disable to Stop Button
        Me.btnStop.Enabled = False
      End If
    End If
  End Sub

  Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
    'Fill the DataGridView from the MS Access database [Cumbria.mdb]
    Me.CumbriaDataTableAdapter.Fill(Me.CumbriaDataSet.CumbriaData)
  End Sub

  Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
    'If process was cancelled by the user..
    If e.Cancelled Then
      Me.lblStatus.Text = "Cancelled"
    Else
      Beep()
      'If process was completed..
      'Force the DataGridView to refresh
      Me.CumbriaDataBindingSource.ResetBindings(False)
      'Show process completed
      Me.lblStatus.Text = "Completed"
      btnStop.Enabled = False
      btnStart.Enabled = True
    End If
  End Sub

End Class





非常感谢您的帮助。这个项目的目的不是商业性的。



Rob Brookes



修改 - 未选中忽略HTML,所以代码片段会显示

推荐答案




这篇关于编译问题的背景工作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:40