私はオンラインで検索していますが、私のエラーのために適切な修正を見つけることができません:Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on.
クロススレッドの問題?
私は私のサイズの変更をどのように呼び出すのですか?いくつかの時間を動作し、他は上記のコードをスロー
私のコードは次のとおりです。
'Handler to handle screen resizes! (Tablet being flipped etc...)
Private Sub TouchRadio_Resize(sender As Object, e As EventArgs) Handles Me.Resize
Dim thread As New Thread(AddressOf resizescreen)
thread.Start()
End Sub
Public Sub resizescreen()
System.Threading.Thread.Sleep(1)
For index As Integer = 1 To 50000
If Screen.PrimaryScreen.Bounds.Width = (Screen.PrimaryScreen.Bounds.Width + 17) Then
Exit For
End If
Dim screenWidth As Integer = Screen.PrimaryScreen.Bounds.Width
screenWidth = (screenWidth + 17)
Dim screenHeight As Integer = Screen.PrimaryScreen.Bounds.Height
Me.Size = New System.Drawing.Size(screenWidth, screenHeight) 'Here it errors at
GeckoWebBrowser1.Size = New System.Drawing.Size(screenWidth, screenHeight)
Me.Location = New Point(0, 0)
Next
End Sub
この方法では、複雑さと冗長性が大幅に低下する可能性があります。 'Me.Location = New Point(0、0)'を50k回呼び出さなければならないのですか? If Screen.PrimaryScreen.Bounds.Width =(Screen.PrimaryScreen.Bounds.Width + 17) 'を等価から> = – djv