Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 阻止Form1上的对话框阻止与Form2的交互?_.net_Vb.net_Winforms_Showdialog - Fatal编程技术网

.net 阻止Form1上的对话框阻止与Form2的交互?

.net 阻止Form1上的对话框阻止与Form2的交互?,.net,vb.net,winforms,showdialog,.net,Vb.net,Winforms,Showdialog,我正在使用一个WinForm应用程序,它有两个窗体。第一种形式是所有逻辑的主要形式。第二个表单拥有一个浏览器控件,并根据从Form1传递的数据访问内部网页。然后可以与web页面进行交互。当在Form1上弹出MessageBox时,问题就出现了。在Form2上,交互被阻止 有没有一种方法可以在MessageBox被应答之前启用Form2的交互 OpenBrowser(docIDs, txtID.Text) Me.Activate() resultYESNO = MessageBox.Show(

我正在使用一个WinForm应用程序,它有两个窗体。第一种形式是所有逻辑的主要形式。第二个表单拥有一个浏览器控件,并根据从Form1传递的数据访问内部网页。然后可以与web页面进行交互。当在Form1上弹出MessageBox时,问题就出现了。在Form2上,交互被阻止

有没有一种方法可以在MessageBox被应答之前启用Form2的交互

OpenBrowser(docIDs, txtID.Text)
 Me.Activate()
 resultYESNO = MessageBox.Show(Me, questionText, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
         If resultYESNO = DialogResult.Yes Then
           columnValue = "Y"
          ElseIf resultYESNO = DialogResult.No Then
           columnValue = "N"
           End If
OpenBrowser子系统:

Private Sub OpenBrowser(ByVal docIDs As List(Of String), ByVal ID As String)
    If Not Application.OpenForms().OfType(Of Browser).Any Then
        Dim browser = New Browser()
    End If
    Dim encodeIDs As String
    encodeIDs = String.Join(",", docIDs.ToArray())
    Dim barray As Byte() = System.Text.Encoding.UTF8.GetBytes(encodeIDs)
    Dim encodedIDs = System.Convert.ToBase64String(barray)
    Dim url = ConfigurationManager.AppSettings("MyBrowserPath")
    Browser.WebBrowser1.Url = New Uri(url & encodedIDs)
    Dim area = Screen.PrimaryScreen.WorkingArea
    Dim width = CInt(area.Width / 2)
    Dim height = CInt(area.Height)
    Browser.Width = width
    Browser.Height = 800
    Browser.SetDesktopLocation(width, 0)
    Browser.Show()
    Browser.BringToFront()
    Browser.Activate()
End Sub

下面的示例演示如何创建不同的UI线程,并在不同的线程上显示不同的表单。然后,模态对话框窗体在创建它们的线程中是模态的:

Imports System.Threading
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        For i = 1 To 2
            Dim index = i
            Dim t = New Thread(
                Sub()
                    Dim f = New Form With {.Text = $"Form {index}"}
                    Dim b = New Button With {.Text = "Click Me."}
                    AddHandler b.Click,
                        Sub()
                            Using d As New Form()
                                d.StartPosition = FormStartPosition.CenterParent
                                d.Size = New Drawing.Size(100, 100)
                                d.ShowDialog()
                            End Using
                        End Sub
                    f.Controls.Add(b)
                    Application.Run(f)
                End Sub)
            t.SetApartmentState(ApartmentState.STA)
            t.IsBackground=True
            t.Start()
        Next
    End Sub
End Class

我们昨天不是已经问过了吗?那是关于用“假”对话框替换对话框。这是在寻找一种不同的方法。为什么在提出问题之前要打开浏览器表单?在回答问题之前需要查看web表单中的数据很久以前,在遥远的银河系中,您曾经能够设置旧MsgBox的模式。现在唯一的选择是ApplicationModel。