1
''//begin cross threaded component
Private Sub dBgRIDvIEWNotInvokeRequired(ByVal dBGridViewcomponentname As DataGridView, ByVal dvalue As String)
dBGridViewcomponentname.Text = dvalue
dBGridViewcomponentname.Update()
End Sub
Private Delegate Sub deldBGrridView(ByVal dBGridViewcomponentname As DataGridView, ByVal dvalue As String)
Private Sub ThreadedDbGridViewAddress(ByVal dBGridViewcomponentname As DataGridView, ByVal dvalue As String)
Try
If InvokeRequired Then
Dim udd As New deldBGrridView(AddressOf ThreadedDbGridViewAddress)
Invoke(udd, New Object() {dBGridViewcomponentname, dvalue})
Else
dBgRIDvIEWNotInvokeRequired(dBGridViewcomponentname, dvalue)
End If
Catch ex As Exception
End Try
End Sub
Private CrossThreadedDbGridView As New deldBGrridView(AddressOf ThreadedDbGridViewAddress)
''//end cross threaded component
このCrossThreadedDbGridView(DataGridView1、 "TheText")のようなものですvb.net一般スレッドセーフwindows.form
しかし、私はメンバーまたは財産の多くを持っている場合このコードのように使用するには:
DbGridPapers.ColumnCount = 5
DbGridPapers.RowCount = rc
DbGridPapers.Update()
DbGridPapers.Columns(0).HeaderText = "PaperSize"
DbGridPapers.Columns(1).HeaderText = "#of_Pages"
DbGridPapers.Columns(2).HeaderText = "#of_Images"
DbGridPapers.Columns(3).HeaderText = "Payable"
DbGridPapers.Columns(4).HeaderText = "CountedImage"
DbGridPapers.Update()
DbGridPapers.Rows(rc).HeaderCell.Value = FileName
DbGridPapers.Rows(rc).Cells(0).Value = xpapersize
DbGridPapers.Rows(rc).Cells(1).Value = xpNumbers
DbGridPapers.Rows(rc).Cells(2).Value = xiNumbers
DbGridPapers.Rows(rc).Cells(3).Value = xTotImageCounts
DbGridPapers.Rows(rc).Cells(4).Value = xTotImageCounts
DbGridPapers.Update()
この単純な、一般的に素晴らしいスレッドセーフにするにはどうすればよいですかeコンポーネント
アイデア?私はこのようにそれらを呼び出すことができること:
CrossThreadedDbGridView(DataGridView1.ColumnCount, 5)
CrossThreadedDbGridView(DataGridView1.RowCount, rc)
CrossThreadedDbGridView(DataGridView1.Columns(0).HeaderText, "PaperSize")
...
...
またはこの
を行うための良い方法はあり休息ように私は問題を解決した、おかげで – XenKid
をstackoverflowの後、あなたがあなた自身の質問に答える必要があります世界の恩恵を受けることができます。 –