title: Why does my MessageBox show so many times?
body: <p><em>I have an application which blocks certain websites using a list of websites from the <strong><code>hosts</code></strong> file, and once that website is blocked, an event is raised, which in my case, a <strong><code>MessageBox</code></strong> is shown.</em></p>
  
  <p><strong>The program works great</strong>, besides <strong><em>1</em></strong> annoying error which I can't seem to resolve, and that is, the <code>MessageBox</code> appears about <strong><em>6</em></strong> times, then, after those <strong><em>6</em></strong> times finishes up, the <strong><em><code>ERR_CONNECTION_RESET</code></em></strong> page appears.</p>
  
  <p>Is there a way to limit the amounts of times a <code>MessageBox</code> is aloud to show, but also letting the traffic come through to get  to the blocked website? </p>
  
  <p><strong>This is</strong> <strong><em>all</em></strong> <strong>of the code I'm using:</strong></p>
  
  <pre><code>Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
          Dim blocker As BlockListener
          Dim thread As Thread
          blocker = New BlockListener
          thread = New Thread(New ThreadStart(AddressOf blocker.listen))
          thread.Start()
          AddHandler blocker.Blocked, AddressOf User_Blocked
  
      End Sub
  
      Private Sub User_Blocked()
          MessageBox.Show("Website successfully blocked!") &lt;-- Shows 6 times!
      End Sub
  
      Public Class BlockListener
          Private port As Integer = 80
          Private listener As TcpListener
          Private BlockUsers As Boolean = True
          Public Event Blocked As EventHandler
  
          Public Sub listen()
  
              listener = New TcpListener(IPAddress.Parse("127.0.0.1"), port)
  
              listener.Start()
  
              While (BlockUsers)
                  Dim clientConnection As TcpClient = listener.AcceptTcpClient
  
                  clientConnection.Close()
  
                  RaiseEvent Blocked(Me, EventArgs.Empty)
              End While
              '
              listener.Stop()
          End Sub
  
      End Class
  </code></pre>