Results 1 to 3 of 3

Thread: Application.DoEvents() Problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Location
    USA
    Posts
    102

    Application.DoEvents() Problem

    Ok I am having a bit of a problem here. I am writing a server in vb.net. I need to run a loop that does not stop until I tell it too by the press of a button. So I put Application.DoEvents() in the loop. However, my program still locks up and will not respond. What is going on. I am using VS.Net 2002 btw.
    ===============
    Tek
    ===============

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Location
    USA
    Posts
    102
    Here is some code for you to look at
    VB Code:
    1. Public Sub StartServer(ByVal Listener As TcpListener, ByVal outputwindow As RichTextBox)
    2.         Dim objSocket As Socket
    3.         Dim bytData(32000) As Byte
    4.         Dim charData() As Char
    5.         Dim J As Integer
    6.         Dim i As Integer
    7.         Dim data As String
    8.  
    9.         Listener.Start()
    10.         outputwindow.Text = outputwindow.Text & vbCrLf & "Server Started"
    11.         While blnListen = True
    12.             Application.DoEvents()
    13.             objSocket = Listener.AcceptSocket()
    14.             J = objSocket.Receive(bytData)
    15.             ReDim charData(bytData.Length)
    16.             While (J <> 0)
    17.                 charData = ConvertToChar(bytData)
    18.                 For i = 0 To charData.Length
    19.                     data = data & charData(i)
    20.                 Next
    21.             End While
    22.             outputwindow.Text = outputwindow.Text & vbCrLf & data
    23.         End While
    24.     End Sub
    ===============
    Tek
    ===============

  3. #3
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    I think you might need another Application.DoEvents() inside the second loop.

    VB Code:
    1. .
    2. .
    3. .
    4. While (J <> 0)
    5.     Application.DoEvents()
    6.     charData = ConvertToChar(bytData)
    7.     For i = 0 To charData.Length
    8.         data = data & charData(i)
    9.     Next
    10. End While
    11. .
    12. .
    13. .
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width